Skip to content

GH-96851: Add link to FAQ entry for caching method calls. #96902

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 1 commit into from
Sep 18, 2022
Merged
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions Doc/faq/programming.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1897,6 +1897,8 @@ The classes can be used like this:
'blog-why-python-rocks'


.. _faq-cache-method-calls:

How do I cache method calls?
----------------------------

Expand Down
3 changes: 3 additions & 0 deletions Doc/library/functools.rst
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,9 @@ The :mod:`functools` module defines the following functions:
The cache keeps references to the arguments and return values until they age
out of the cache or until the cache is cleared.

If a method is cached, the `self` instance argument is included in the
cache. See :ref:`faq-cache-method-calls`

An `LRU (least recently used) cache
<https://en.wikipedia.org/wiki/Cache_replacement_policies#Least_recently_used_(LRU)>`_
works best when the most recent calls are the best predictors of upcoming
Expand Down