Skip to content

Commit

Permalink
pythonGH-96851: Add link to FAQ entry for caching method calls. (pyth…
Browse files Browse the repository at this point in the history
…onGH-96902)

(cherry picked from commit bbc24b2)

Co-authored-by: Raymond Hettinger <rhettinger@users.noreply.github.com>
  • Loading branch information
miss-islington and rhettinger authored Sep 18, 2022
1 parent 9b789e5 commit 8e2bda8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
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 @@ -191,6 +191,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

0 comments on commit 8e2bda8

Please sign in to comment.