Speed-up cache updates

This commit is contained in:
Raymond Hettinger 2010-09-02 09:44:28 +00:00
parent ccb90e3ccd
commit 38d17e3df0
2 changed files with 14 additions and 2 deletions

View file

@ -139,8 +139,7 @@ def lru_cache(maxsize=100):
try:
with lock:
result = cache[key]
del cache[key]
cache[key] = result # record recent use of this key
cache._move_to_end(key) # record recent use of this key
wrapper.hits += 1
except KeyError:
result = user_function(*args, **kwds)