Skip to content

Commit

Permalink
bpo-35300: Add usage note to the lru_cache() docs (GH-10707) (GH-10708)
Browse files Browse the repository at this point in the history
  • Loading branch information
miss-islington authored and rhettinger committed Nov 26, 2018
1 parent 6a528cc commit c707400
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Doc/library/functools.rst
Expand Up @@ -85,6 +85,11 @@ The :mod:`functools` module defines the following functions:
The cache's size limit assures that the cache does not grow without bound on
long-running processes such as web servers.

In general, the LRU cache should only be used when you want to reuse
previously computed values. Accordingly, it doesn't make sense to cache
functions with side-effects, functions that need to create distinct mutable
objects on each call, or impure functions such as time() or random().

Example of an LRU cache for static web content::

@lru_cache(maxsize=32)
Expand Down

0 comments on commit c707400

Please sign in to comment.