]> git.gag.com Git - debian/gnuradio/commitdiff
Restored the eval cache. Use a hash of the code+namespace rather than a copy of the...
authorjblum <jblum@221aa14e-8319-0410-a670-987f0aec2ac5>
Mon, 1 Jun 2009 06:34:22 +0000 (06:34 +0000)
committerjblum <jblum@221aa14e-8319-0410-a670-987f0aec2ac5>
Mon, 1 Jun 2009 06:34:22 +0000 (06:34 +0000)
git-svn-id: http://gnuradio.org/svn/gnuradio/trunk@11169 221aa14e-8319-0410-a670-987f0aec2ac5

grc/src/platforms/python/FlowGraph.py

index b2863ef7203d27c752daa5e087b75a396e495ba0..d0b997a5850d114139fa103ebc0caf797a1afb8f 100644 (file)
@@ -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):
                """