[Python-checkins] cpython (merge 3.3 -> default): merge
raymond.hettinger
python-checkins at python.org
Mon Mar 4 09:54:57 CET 2013
http://hg.python.org/cpython/rev/c761011eb02c
changeset: 82469:c761011eb02c
parent: 82467:af1961e38ccb
parent: 82468:4b06fd08b78c
user: Raymond Hettinger <python at rcn.com>
date: Mon Mar 04 03:54:45 2013 -0500
summary:
merge
files:
Lib/functools.py | 18 +++++++++++-------
1 files changed, 11 insertions(+), 7 deletions(-)
diff --git a/Lib/functools.py b/Lib/functools.py
--- a/Lib/functools.py
+++ b/Lib/functools.py
@@ -291,19 +291,23 @@
# computed result and update the count of misses.
pass
elif full:
- # use root to store the new key and result
- root[KEY] = key
- root[RESULT] = result
- cache[key] = root
+ # use the old root to store the new key and result
+ oldroot = root
+ oldroot[KEY] = key
+ oldroot[RESULT] = result
# empty the oldest link and make it the new root
- root = root[NEXT]
- del cache[root[KEY]]
+ root = oldroot[NEXT]
+ oldkey = root[KEY]
+ oldvalue = root[RESULT]
root[KEY] = root[RESULT] = None
+ # now update the cache dictionary for the new links
+ del cache[oldkey]
+ cache[key] = oldroot
else:
# put result in a new link at the front of the queue
last = root[PREV]
link = [last, root, key, result]
- cache[key] = last[NEXT] = root[PREV] = link
+ last[NEXT] = root[PREV] = cache[key] = link
full = (len(cache) == maxsize)
misses += 1
return result
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list