From 39283663bffc56ae47b34058f367896a1e77692b Mon Sep 17 00:00:00 2001 From: jblum Date: Mon, 1 Jun 2009 06:34:22 +0000 Subject: [PATCH] Restored the eval cache. Use a hash of the code+namespace rather than a copy of the code + namespace objects which causes issue. git-svn-id: http://gnuradio.org/svn/gnuradio/trunk@11169 221aa14e-8319-0410-a670-987f0aec2ac5 --- grc/src/platforms/python/FlowGraph.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/grc/src/platforms/python/FlowGraph.py b/grc/src/platforms/python/FlowGraph.py index b2863ef7..d0b997a5 100644 --- a/grc/src/platforms/python/FlowGraph.py +++ b/grc/src/platforms/python/FlowGraph.py @@ -35,7 +35,7 @@ def _get_value_expr(variable_block): class FlowGraph(_FlowGraph): - #_eval_cache = dict() + _eval_cache = dict() def _eval(self, code, namespace): """ Evaluate the code with the given namespace. @@ -43,13 +43,12 @@ class FlowGraph(_FlowGraph): @param namespace a dict representing the namespace @return the resultant object """ - #check cache - #if self._eval_cache.has_key(code) and self._eval_cache[code][0] == namespace: - # return self._eval_cache[code][1] - #evaluate - result = eval(code, namespace, namespace) - #self._eval_cache[code] = (namespace.copy(), result) - return result + my_hash = hash(code + str(namespace)) + #cache if does not exist + if not self._eval_cache.has_key(my_hash): + self._eval_cache[my_hash] = eval(code, namespace, namespace) + #return from cache + return self._eval_cache[my_hash] def _get_io_signature(self, pad_key): """ -- 2.47.2