From 1f034ed7670c65805fe4ffed03852b9dcd4adb3a Mon Sep 17 00:00:00 2001 From: Raymond Hettinger Date: Sat, 13 Aug 2022 15:25:22 -0500 Subject: [PATCH] GH-93179: Document the thread safety of functools.lru_cache --- Doc/library/functools.rst | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Doc/library/functools.rst b/Doc/library/functools.rst index 00aca09bc7af45..47cbe59fa49222 100644 --- a/Doc/library/functools.rst +++ b/Doc/library/functools.rst @@ -49,6 +49,9 @@ 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. + .. versionadded:: 3.9 @@ -140,6 +143,9 @@ 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. + Since a dictionary is used to cache results, the positional and keyword arguments to the function must be hashable.