summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2023-04-22 15:54:58 (GMT)
committerGitHub <noreply@github.com>2023-04-22 15:54:58 (GMT)
commit7f6710bab62f8c30eb432b5024075ae5bf98aef7 (patch)
tree5a33866d0b745a2472e0ad69f50969d8c1128a79
parentb2fdae9d86cd91fc75ca6a91f772cf805d536f42 (diff)
downloadcpython-7f6710bab62f8c30eb432b5024075ae5bf98aef7.zip
cpython-7f6710bab62f8c30eb432b5024075ae5bf98aef7.tar.gz
cpython-7f6710bab62f8c30eb432b5024075ae5bf98aef7.tar.bz2
[3.11] GH-103475: cache() and lru_cache() do not have a "call once" guarantee (GH-103669) (#103682)
GH-103475: cache() and lru_cache() do not have a "call once" guarantee (GH-103669) (cherry picked from commit e5eaac6064561c8f7643011a31fa506e78330798) Co-authored-by: Raymond Hettinger <rhettinger@users.noreply.github.com>
-rw-r--r--Doc/library/functools.rst18
1 files changed, 14 insertions, 4 deletions
diff --git a/Doc/library/functools.rst b/Doc/library/functools.rst
index 80a405e..7438d4c 100644
--- a/Doc/library/functools.rst
+++ b/Doc/library/functools.rst
@@ -49,8 +49,13 @@ The :mod:`functools` module defines the following functions:
>>> factorial(12) # makes two new recursive calls, the other 10 are cached
479001600
- The cache is threadsafe so the wrapped function can be used in multiple
- threads.
+ The cache is threadsafe so that the wrapped function can be used in
+ multiple threads. This means that the underlying data structure will
+ remain coherent during concurrent updates.
+
+ It is possible for the wrapped function to be called more than once if
+ another thread makes an additional call before the initial call has been
+ completed and cached.
.. versionadded:: 3.9
@@ -143,8 +148,13 @@ The :mod:`functools` module defines the following functions:
*maxsize* most recent calls. It can save time when an expensive or I/O bound
function is periodically called with the same arguments.
- The cache is threadsafe so the wrapped function can be used in multiple
- threads.
+ The cache is threadsafe so that the wrapped function can be used in
+ multiple threads. This means that the underlying data structure will
+ remain coherent during concurrent updates.
+
+ It is possible for the wrapped function to be called more than once if
+ another thread makes an additional call before the initial call has been
+ completed and cached.
Since a dictionary is used to cache results, the positional and keyword
arguments to the function must be :term:`hashable`.