File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed
Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -50,13 +50,23 @@ The :mod:`functools` module defines the following functions:
5050 479001600
5151
5252 The cache is threadsafe so that the wrapped function can be used in
53- multiple threads. This means that the underlying data structure will
53+ multiple threads. This means that the underlying data structure will
5454 remain coherent during concurrent updates.
5555
5656 It is possible for the wrapped function to be called more than once if
5757 another thread makes an additional call before the initial call has been
5858 completed and cached.
5959
60+ In particular, when the same key is computed concurrently in multiple
61+ threads, each thread may execute the wrapped function independently
62+ before the first result is stored in the cache. As a consequence, the
63+ return values from these concurrent calls may be distinct objects even
64+ though they correspond to the same cache key.
65+
66+ This behavior means that ``lru_cache `` should not be relied upon for
67+ singleton object creation or other scenarios requiring that only one
68+ instance be constructed for a given key without external synchronization.
69+
6070 .. versionadded :: 3.9
6171
6272
You can’t perform that action at this time.
0 commit comments