[Python-checkins] bpo-40651: Improve LRU recipe in the OrderedDict documentation (GH-GH-20139) (GH-20167)

Miss Islington (bot) webhook-mailer at python.org
Thu May 21 00:21:10 EDT 2020


https://github.com/python/cpython/commit/d88f0aa8e24ea7562f2e04833f46d8526e846334
commit: d88f0aa8e24ea7562f2e04833f46d8526e846334
branch: 3.8
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: GitHub <noreply at github.com>
date: 2020-05-20T21:21:02-07:00
summary:

bpo-40651: Improve LRU recipe in the OrderedDict documentation  (GH-GH-20139) (GH-20167)

files:
M Doc/library/collections.rst

diff --git a/Doc/library/collections.rst b/Doc/library/collections.rst
index 8dcf9451d72bf..d4297166597b6 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))



More information about the Python-checkins mailing list