diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2020-05-21 04:21:02 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-21 04:21:02 (GMT) |
commit | d88f0aa8e24ea7562f2e04833f46d8526e846334 (patch) | |
tree | dda0c1c824ca2c801f70ed3f3b77b1bd6dcae4e7 | |
parent | a59fc9160db50a5e20358303e7ddbda180a1b74f (diff) | |
download | cpython-d88f0aa8e24ea7562f2e04833f46d8526e846334.zip cpython-d88f0aa8e24ea7562f2e04833f46d8526e846334.tar.gz cpython-d88f0aa8e24ea7562f2e04833f46d8526e846334.tar.bz2 |
bpo-40651: Improve LRU recipe in the OrderedDict documentation (GH-GH-20139) (GH-20167)
-rw-r--r-- | Doc/library/collections.rst | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/Doc/library/collections.rst b/Doc/library/collections.rst index 8dcf945..d429716 100644 --- a/Doc/library/collections.rst +++ b/Doc/library/collections.rst @@ -1150,6 +1150,8 @@ variants of :func:`functools.lru_cache`:: return value def __setitem__(self, key, value): + if key in self: + self.move_to_end(key) super().__setitem__(key, value) if len(self) > self.maxsize: oldest = next(iter(self)) |