Commits

AJ R committed 6a514d2 Merge

Merged in j0z3f/savreaderwriter (pull request #3)

Fixed memoize to prevent currently cached item from getting removed

  • Participants
  • Parent commits f276ec4, 341b98e

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