summaryrefslogtreecommitdiffstats
path: root/Doc
diff options
context:
space:
mode:
authorRaymond Hettinger <rhettinger@users.noreply.github.com>2021-06-19 00:19:32 (GMT)
committerGitHub <noreply@github.com>2021-06-19 00:19:32 (GMT)
commite5c7ee1156986c2046799ce523f0df54af51b7a3 (patch)
tree73b6a1998fdffba363e16fa939b6f75efccc181a /Doc
parent83c9dad8da5fc90b717eef683304aaa49448615a (diff)
downloadcpython-e5c7ee1156986c2046799ce523f0df54af51b7a3.zip
cpython-e5c7ee1156986c2046799ce523f0df54af51b7a3.tar.gz
cpython-e5c7ee1156986c2046799ce523f0df54af51b7a3.tar.bz2
Remove dubious suggestion (GH-26789)
Remove the weakref example. If a new instance is created and the same arguments are passes, it raises a ReferenceError.
Diffstat (limited to 'Doc')
-rw-r--r--Doc/faq/programming.rst18
1 files changed, 0 insertions, 18 deletions
diff --git a/Doc/faq/programming.rst b/Doc/faq/programming.rst
index a519275..af4b489 100644
--- a/Doc/faq/programming.rst
+++ b/Doc/faq/programming.rst
@@ -1852,14 +1852,6 @@ bounded by the specified *maxsize*. The disadvantage is that instances
are kept alive until they age out of the cache or until the cache is
cleared.
-To avoid keeping an instance alive, it can be wrapped a weak reference
-proxy. That allows an instance to be freed prior aging out of the LRU
-cache. That said, the weak reference technique is rarely needed. It is
-only helpful when the instances hold large amounts of data and the
-normal aging-out process isn't fast enough. And even though the
-instance is released early, the cache still keeps references to the
-other method arguments and to the result of the method call.
-
This example shows the various techniques::
class Weather:
@@ -1884,16 +1876,6 @@ This example shows the various techniques::
"Rainfall on a given date"
# Depends on the station_id, date, and units.
- def climate(self, category='average_temperature'):
- "List of daily average temperatures for a full year"
- return self._climate(weakref.proxy(self), category)
-
- @staticmethod
- @lru_cache(maxsize=10)
- def _climate(self_proxy, category):
- # Depends on a weak reference to the instance
- # and on the category parameter.
-
The above example assumes that the *station_id* never changes. If the
relevant instance attributes are mutable, the *cached_property* approach
can't be made to work because it cannot detect changes to the