diff options
author | jblum <jblum@221aa14e-8319-0410-a670-987f0aec2ac5> | 2009-06-01 06:34:22 +0000 |
---|---|---|
committer | jblum <jblum@221aa14e-8319-0410-a670-987f0aec2ac5> | 2009-06-01 06:34:22 +0000 |
commit | 39283663bffc56ae47b34058f367896a1e77692b (patch) | |
tree | e875f80ff957bed84c4fd266bf3c9aacef6314fb /grc/src/platforms/python/FlowGraph.py | |
parent | f5ddbb8cef11c08a55018317a609a798a222809f (diff) |
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
Diffstat (limited to 'grc/src/platforms/python/FlowGraph.py')
-rw-r--r-- | grc/src/platforms/python/FlowGraph.py | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/grc/src/platforms/python/FlowGraph.py b/grc/src/platforms/python/FlowGraph.py index b2863ef720..d0b997a585 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): """ |