Skip to content

Commit 3cb70ab

Browse files
Remove dubious suggestion (GH-26789) (#26797)
1 parent 1b4addf commit 3cb70ab

File tree

1 file changed

+0
-18
lines changed

1 file changed

+0
-18
lines changed

Doc/faq/programming.rst

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1852,14 +1852,6 @@ bounded by the specified *maxsize*. The disadvantage is that instances
18521852
are kept alive until they age out of the cache or until the cache is
18531853
cleared.
18541854

1855-
To avoid keeping an instance alive, it can be wrapped a weak reference
1856-
proxy. That allows an instance to be freed prior aging out of the LRU
1857-
cache. That said, the weak reference technique is rarely needed. It is
1858-
only helpful when the instances hold large amounts of data and the
1859-
normal aging-out process isn't fast enough. And even though the
1860-
instance is released early, the cache still keeps references to the
1861-
other method arguments and to the result of the method call.
1862-
18631855
This example shows the various techniques::
18641856

18651857
class Weather:
@@ -1884,16 +1876,6 @@ This example shows the various techniques::
18841876
"Rainfall on a given date"
18851877
# Depends on the station_id, date, and units.
18861878

1887-
def climate(self, category='average_temperature'):
1888-
"List of daily average temperatures for a full year"
1889-
return self._climate(weakref.proxy(self), category)
1890-
1891-
@staticmethod
1892-
@lru_cache(maxsize=10)
1893-
def _climate(self_proxy, category):
1894-
# Depends on a weak reference to the instance
1895-
# and on the category parameter.
1896-
18971879
The above example assumes that the *station_id* never changes. If the
18981880
relevant instance attributes are mutable, the *cached_property* approach
18991881
can't be made to work because it cannot detect changes to the

0 commit comments

Comments
 (0)