https://github.com/python/cpython/commit/5b299bb81e35c6dd2c597140502eaeaa985a4504 commit: 5b299bb81e35c6dd2c597140502eaeaa985a4504 branch: 3.14 author: Miss Islington (bot) <[email protected]> committer: sobolevn <[email protected]> date: 2026-06-06T01:59:42+03:00 summary:
[3.14] Use `time.monotonic` in OrderedDict LRU cache example (GH-150986) (#150992) Use `time.monotonic` in OrderedDict LRU cache example (GH-150986) (cherry picked from commit ea4c85552bb7883e1d6c808281c1f46aca86aeab) Co-authored-by: Ilya Nikolaev <[email protected]> files: M Doc/library/collections.rst diff --git a/Doc/library/collections.rst b/Doc/library/collections.rst index c37cb6ba786672..cfae8104062418 100644 --- a/Doc/library/collections.rst +++ b/Doc/library/collections.rst @@ -1229,7 +1229,7 @@ variants of :func:`functools.lru_cache`: .. testcode:: from collections import OrderedDict - from time import time + from time import monotonic class TimeBoundedLRU: "LRU Cache that invalidates and refreshes old entries." @@ -1244,10 +1244,10 @@ variants of :func:`functools.lru_cache`: if args in self.cache: self.cache.move_to_end(args) timestamp, result = self.cache[args] - if time() - timestamp <= self.maxage: + if monotonic() - timestamp <= self.maxage: return result result = self.func(*args) - self.cache[args] = time(), result + self.cache[args] = monotonic(), result if len(self.cache) > self.maxsize: self.cache.popitem(last=False) return result _______________________________________________ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3//lists/python-checkins.python.org Member address: [email protected]
