Skip to content

Commit e5eaac6

Browse files
authored
GH-103475: cache() and lru_cache() do not have a "call once" guarantee (GH-103669)
1 parent 7b134d3 commit e5eaac6

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

Doc/library/functools.rst

+14-4
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

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

161-
The cache is threadsafe so the wrapped function can be used in multiple
162-
threads.
166+
The cache is threadsafe so that the wrapped function can be used in
167+
multiple threads. This means that the underlying data structure will
168+
remain coherent during concurrent updates.
169+
170+
It is possible for the wrapped function to be called more than once if
171+
another thread makes an additional call before the initial call has been
172+
completed and cached.
163173

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

0 commit comments

Comments
 (0)