bpo-40651: Improve LRU recipe in the OrderedDict documentation (GH-GH-20139) (GH-20167)
This commit is contained in:
parent
a59fc9160d
commit
d88f0aa8e2
|
@ -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))
|
||||
|
|
Loading…
Reference in New Issue