]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-35300: Add usage note to the lru_cache() docs (GH-10707) (GH-10709)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Mon, 26 Nov 2018 01:01:09 +0000 (17:01 -0800)
committerRaymond Hettinger <rhettinger@users.noreply.github.com>
Mon, 26 Nov 2018 01:01:09 +0000 (17:01 -0800)
Doc/library/functools.rst

index b221a8584a12aafd98d214baee52ab9ae0d0be7a..41c06c647b78240649c95c1fb8686ca613844f6e 100644 (file)
@@ -80,6 +80,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)