commit-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Commit-gnuradio] r11169 - gnuradio/trunk/grc/src/platforms/python


From: jblum
Subject: [Commit-gnuradio] r11169 - gnuradio/trunk/grc/src/platforms/python
Date: Mon, 1 Jun 2009 00:34:22 -0600 (MDT)

Author: jblum
Date: 2009-06-01 00:34:22 -0600 (Mon, 01 Jun 2009)
New Revision: 11169

Modified:
   gnuradio/trunk/grc/src/platforms/python/FlowGraph.py
Log:
Restored the eval cache. Use a hash of the code+namespace rather than a copy of 
the code + namespace objects which causes issue.



Modified: gnuradio/trunk/grc/src/platforms/python/FlowGraph.py
===================================================================
--- gnuradio/trunk/grc/src/platforms/python/FlowGraph.py        2009-06-01 
05:01:16 UTC (rev 11168)
+++ gnuradio/trunk/grc/src/platforms/python/FlowGraph.py        2009-06-01 
06:34:22 UTC (rev 11169)
@@ -35,7 +35,7 @@
 
 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 @@
                @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):
                """





reply via email to

[Prev in Thread] Current Thread [Next in Thread]