8000 bpo-35300: Add usage note to the lru_cache() docs (GH-10707) · python/cpython@f0e0f20 · GitHub
[go: up one dir, main page]

Skip to content

Commit f0e0f20

Browse files
rhettingermiss-islington
authored andcommitted
bpo-35300: Add usage note to the lru_cache() docs (GH-10707)
https://bugs.python.org/issue35300
1 parent ec13b93 commit f0e0f20

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

Doc/library/functools.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,11 @@ The :mod:`functools` module defines the following functions:
118118
The cache's size limit assures that the cache does not grow without bound on
119119
long-running processes such as web servers.
120120

121+
In general, the LRU cache should only be used when you want to reuse
122+
previously computed values. Accordingly, it doesn't make sense to cache
123+
functions with side-effects, functions that need to create distinct mutable
124+
objects on each call, or impure functions such as time() or random().
125+
121126
Example of an LRU cache for static web content::
122127

123128
@lru_cache(maxsize=32)

0 commit comments

Comments
 (0)
0