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

Skip to content

Commit c707400

Browse files
miss-islingtonrhettinger
authored andcommitted
bpo-35300: Add usage note to the lru_cache() docs (GH-10707) (GH-10708)
1 parent 6a528cc commit c707400

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
@@ -85,6 +85,11 @@ The :mod:`functools` module defines the following functions:
8585
The cache's size limit assures that the cache does not grow without bound on
8686
long-running processes such as web servers.
8787

88+
In general, the LRU cache should only be used when you want to reuse
< 5DF2 /td>
89+
previously computed values. Accordingly, it doesn't make sense to cache
90+
functions with side-effects, functions that need to create distinct mutable
91+
objects on each call, or impure functions such as time() or random().
92+
8893
Example of an LRU cache for static web content::
8994

9095
@lru_cache(maxsize=32)

0 commit comments

Comments
 (0)
0