summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRaymond Hettinger <rhettinger@users.noreply.github.com>2021-11-09 23:01:29 (GMT)
committerGitHub <noreply@github.com>2021-11-09 23:01:29 (GMT)
commit912a4ccc3a523e2990cc501393adfc661614c73a (patch)
tree934dec6c68afeb17315f8e7833f4b7bf8669312f
parent49171aa91ab78c2608a26e5a75cdceab3bad6176 (diff)
downloadcpython-912a4ccc3a523e2990cc501393adfc661614c73a.zip
cpython-912a4ccc3a523e2990cc501393adfc661614c73a.tar.gz
cpython-912a4ccc3a523e2990cc501393adfc661614c73a.tar.bz2
bpo-45701: Improve documentation for *typed* parameter (GH-29498)
-rw-r--r--Doc/library/functools.rst14
1 files changed, 10 insertions, 4 deletions
diff --git a/Doc/library/functools.rst b/Doc/library/functools.rst
index a01b172..c78818b 100644
--- a/Doc/library/functools.rst
+++ b/Doc/library/functools.rst
@@ -160,10 +160,16 @@ The :mod:`functools` module defines the following functions:
grow without bound.
If *typed* is set to true, function arguments of different types will be
- cached separately. For example, ``f(3)`` and ``f(3.0)`` will always be
- treated as distinct calls with distinct results. If *typed* is false,
- the implementation will usually but not always regard them as equivalent
- calls and only cache a single result.
+ cached separately. If *typed* is false, the implementation will usually
+ regard them as equivalent calls and only cache a single result. (Some
+ types such as *str* and *int* may be cached separately even when *typed*
+ is false.)
+
+ Note, type specificity applies only to the function's immediate arguments
+ rather than their contents. The scalar arguments, ``Decimal(42)`` and
+ ``Fraction(42)`` are be treated as distinct calls with distinct results.
+ In contrast, the tuple arguments ``('answer', Decimal(42))`` and
+ ``('answer', Fraction(42))`` are treated as equivalent.
The wrapped function is instrumented with a :func:`cache_parameters`
function that returns a new :class:`dict` showing the values for *maxsize*