gh-107421: Clarify `OrderedDict` Examples and Recipes (#107613)

This commit is contained in:
shailshouryya 2023-08-10 21:43:13 -07:00 committed by GitHub
parent 50bbc56009
commit 23a6db98f2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 3 deletions

View File

@ -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::