]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-105172: Fixed functools.lru_cache typed argument docstring. (GH-105173)
authorBar Harel <bharel@barharel.com>
Wed, 31 May 2023 22:56:06 +0000 (23:56 +0100)
committerGitHub <noreply@github.com>
Wed, 31 May 2023 22:56:06 +0000 (17:56 -0500)
Lib/functools.py
Misc/NEWS.d/next/Documentation/2023-05-31-23-05-51.gh-issue-105172.SVfvkD.rst [new file with mode: 0644]

index 72b2103e7a5544c8599038a65bbf4d943bb2b0b0..4d5e2709007843d7682e67c47263bd8f37a505aa 100644 (file)
@@ -483,8 +483,9 @@ def lru_cache(maxsize=128, typed=False):
     can grow without bound.
 
     If *typed* is True, arguments of different types will be cached separately.
-    For example, f(3.0) and f(3) will be treated as distinct calls with
-    distinct results.
+    For example, f(decimal.Decimal("3.0")) and f(3.0) will be treated as
+    distinct calls with distinct results. Some types such as str and int may
+    be cached separately even when typed is false.
 
     Arguments to the cached function must be hashable.
 
diff --git a/Misc/NEWS.d/next/Documentation/2023-05-31-23-05-51.gh-issue-105172.SVfvkD.rst b/Misc/NEWS.d/next/Documentation/2023-05-31-23-05-51.gh-issue-105172.SVfvkD.rst
new file mode 100644 (file)
index 0000000..96cf722
--- /dev/null
@@ -0,0 +1,2 @@
+Fixed :func:`functools.lru_cache` docstring accounting for ``typed``
+argument's different handling of str and int. Patch by Bar Harel.