Commits

Jozef Leskovec committed 341b98e

Fixed memoize to prevent currently cached item from getting removed.

Comments (0)

Files changed (1)

savReaderWriter/savReader.py

         MAXCACHE = 10**4
 
         def memf(*x):
+            if len(cache) >= MAXCACHE:
+                cache.popitem()
             if x not in cache:
                 cache[x] = f(*x)
-            if len(cache) > MAXCACHE:
-                cache.popitem()
             return cache[x]
         return memf