Skip to content

Commit 7f6710b

Browse files
[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 e5eaac6) Co-authored-by: Raymond Hettinger <[email protected]>
1 parent b2fdae9 commit 7f6710b

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

Doc/library/functools.rst

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,13 @@ The :mod:`functools` module defines the following functions:
4949
>>> factorial(12) # makes two new recursive calls, the other 10 are cached
5050
479001600
5151

52-
The cache is threadsafe so the wrapped function can be used in multiple
53-
threads.
52+
The cache is threadsafe so that the wrapped function can be used in
53+
multiple threads. This means that the underlying data structure will
54+
remain coherent during concurrent updates.
55+
56+
It is possible for the wrapped function to be called more than once if
57+
another thread makes an additional call before the initial call has been
58+
completed and cached.
5459

5560
.. versionadded:: 3.9
5661

@@ -143,8 +148,13 @@ The :mod:`functools` module defines the following functions:
143148
*maxsize* most recent calls. It can save time when an expensive or I/O bound
144149
function is periodically called with the same arguments.
145150

146-
The cache is threadsafe so the wrapped function can be used in multiple
147-
threads.
151+
The cache is threadsafe so that the wrapped function can be used in
152+
multiple threads. This means that the underlying data structure will
153+
remain coherent during concurrent updates.
154+
155+
It is possible for the wrapped function to be called more than once if
156+
another thread makes an additional call before the initial call has been
157+
completed and cached.
148158

149159
Since a dictionary is used to cache results, the positional and keyword
150160
arguments to the function must be :term:`hashable`.

0 commit comments

Comments
 (0)