Skip to content

Commit 8e2bda8

Browse files
GH-96851: Add link to FAQ entry for caching method calls. (GH-96902)
(cherry picked from commit bbc24b2) Co-authored-by: Raymond Hettinger <[email protected]>
1 parent 9b789e5 commit 8e2bda8

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

Doc/faq/programming.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1897,6 +1897,8 @@ The classes can be used like this:
18971897
'blog-why-python-rocks'
18981898

18991899

1900+
.. _faq-cache-method-calls:
1901+
19001902
How do I cache method calls?
19011903
----------------------------
19021904

Doc/library/functools.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,9 @@ The :mod:`functools` module defines the following functions:
191191
The cache keeps references to the arguments and return values until they age
192192
out of the cache or until the cache is cleared.
193193

194+
If a method is cached, the `self` instance argument is included in the
195+
cache. See :ref:`faq-cache-method-calls`
196+
194197
An `LRU (least recently used) cache
195198
<https://en.wikipedia.org/wiki/Cache_replacement_policies#Least_recently_used_(LRU)>`_
196199
works best when the most recent calls are the best predictors of upcoming

0 commit comments

Comments
 (0)