mirror of https://github.com/python/cpython
gh-107421: Clarify `OrderedDict` Examples and Recipes (#107613)
This commit is contained in:
parent
50bbc56009
commit
23a6db98f2
|
@ -1224,7 +1224,7 @@ variants of :func:`functools.lru_cache`:
|
|||
result = self.func(*args)
|
||||
self.cache[args] = time(), result
|
||||
if len(self.cache) > self.maxsize:
|
||||
self.cache.popitem(0)
|
||||
self.cache.popitem(last=False)
|
||||
return result
|
||||
|
||||
|
||||
|
@ -1256,12 +1256,12 @@ variants of :func:`functools.lru_cache`:
|
|||
if self.requests[args] <= self.cache_after:
|
||||
self.requests.move_to_end(args)
|
||||
if len(self.requests) > self.maxrequests:
|
||||
self.requests.popitem(0)
|
||||
self.requests.popitem(last=False)
|
||||
else:
|
||||
self.requests.pop(args, None)
|
||||
self.cache[args] = result
|
||||
if len(self.cache) > self.maxsize:
|
||||
self.cache.popitem(0)
|
||||
self.cache.popitem(last=False)
|
||||
return result
|
||||
|
||||
.. doctest::
|
||||
|
|
Loading…
Reference in New Issue