Skip to content

bpo-45701: Improve documentation for *typed* parameter #29498

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 18 commits into from
Nov 9, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions Doc/library/functools.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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*
Expand Down