diff options
author | Raymond Hettinger <python@rcn.com> | 2010-09-02 09:44:28 (GMT) |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2010-09-02 09:44:28 (GMT) |
commit | 38d17e3df030e443653b8999a2e3ccf12968c9ae (patch) | |
tree | f96308bd8939a4bc9eef6cbf7beb33f56a8563eb /Lib/collections.py | |
parent | ccb90e3ccd60bc0156905510074dce84e5b1272c (diff) | |
download | cpython-38d17e3df030e443653b8999a2e3ccf12968c9ae.zip cpython-38d17e3df030e443653b8999a2e3ccf12968c9ae.tar.gz cpython-38d17e3df030e443653b8999a2e3ccf12968c9ae.tar.bz2 |
Speed-up cache updates
Diffstat (limited to 'Lib/collections.py')
-rw-r--r-- | Lib/collections.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/Lib/collections.py b/Lib/collections.py index 1a43afb..6daa596 100644 --- a/Lib/collections.py +++ b/Lib/collections.py @@ -161,6 +161,19 @@ class OrderedDict(dict, MutableMapping): def __del__(self): self.clear() # eliminate cyclical references + def _move_to_end(self, key, PREV=0, NEXT=1): + 'Fast version of self[key]=self.pop(key). Private method for internal use.' + link = self.__map[key] + link_prev = link[PREV] + link_next = link[NEXT] + link_prev[NEXT] = link_next + link_next[PREV] = link_prev + root = self.__root + last = root[PREV] + link[PREV] = last + link[NEXT] = root + last[NEXT] = root[PREV] = link + ################################################################################ ### namedtuple |