Skip to content
Closed
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
5 changes: 5 additions & 0 deletions Doc/library/functools.rst
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,11 @@ The :mod:`functools` module defines the following functions:
functions with side-effects, functions that need to create distinct mutable
objects on each call, or impure functions such as time() or random().

The LRU cache takes string references to the arguments provided in the decorated callable
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The LRU cache takes string references to the arguments provided in the decorated callable
The LRU cache takes strong references to the arguments provided in the decorated callable

as well as the return value. Notice that this means that if a class method is decorated, the cache
will keep strong references to all arguments provided, including the instance itself (provided as the
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
will keep strong references to all arguments provided, including the instance itself (provided as the
will keep strong references to all arguments provided, including the instance itself (provided as first the

argument of the method, normally called ``self``). This has the consequence that calling the cached
method will keep the instances alive until they are discarded by the cache or manually removed.
Example of an LRU cache for static web content::

@lru_cache(maxsize=32)
Expand Down