[Python-checkins] bpo-35300: Add usage note to the lru_cache() docs (GH-10707) (GH-10709)

Raymond Hettinger webhook-mailer at python.org
Sun Nov 25 20:01:12 EST 2018


https://github.com/python/cpython/commit/6c12091ca67e8ec2960652ef7a763d0de772f799
commit: 6c12091ca67e8ec2960652ef7a763d0de772f799
branch: 3.6
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: Raymond Hettinger <rhettinger at users.noreply.github.com>
date: 2018-11-25T17:01:09-08:00
summary:

bpo-35300: Add usage note to the lru_cache() docs (GH-10707) (GH-10709)

files:
M Doc/library/functools.rst

diff --git a/Doc/library/functools.rst b/Doc/library/functools.rst
index b221a8584a12..41c06c647b78 100644
--- a/Doc/library/functools.rst
+++ b/Doc/library/functools.rst
@@ -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)



More information about the Python-checkins mailing list