mirror of https://github.com/python/cpython
GH-103475: cache() and lru_cache() do not have a "call once" guarantee (GH-103669)
This commit is contained in:
parent
7b134d3e71
commit
e5eaac6064
|
@ -49,8 +49,13 @@ The :mod:`functools` module defines the following functions:
|
||||||
>>> factorial(12) # makes two new recursive calls, the other 10 are cached
|
>>> factorial(12) # makes two new recursive calls, the other 10 are cached
|
||||||
479001600
|
479001600
|
||||||
|
|
||||||
The cache is threadsafe so the wrapped function can be used in multiple
|
The cache is threadsafe so that the wrapped function can be used in
|
||||||
threads.
|
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
|
.. versionadded:: 3.9
|
||||||
|
|
||||||
|
@ -158,8 +163,13 @@ The :mod:`functools` module defines the following functions:
|
||||||
*maxsize* most recent calls. It can save time when an expensive or I/O bound
|
*maxsize* most recent calls. It can save time when an expensive or I/O bound
|
||||||
function is periodically called with the same arguments.
|
function is periodically called with the same arguments.
|
||||||
|
|
||||||
The cache is threadsafe so the wrapped function can be used in multiple
|
The cache is threadsafe so that the wrapped function can be used in
|
||||||
threads.
|
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
|
Since a dictionary is used to cache results, the positional and keyword
|
||||||
arguments to the function must be :term:`hashable`.
|
arguments to the function must be :term:`hashable`.
|
||||||
|
|
Loading…
Reference in New Issue