@@ -1852,14 +1852,6 @@ bounded by the specified *maxsize*. The disadvantage is that instances
18521852are kept alive until they age out of the cache or until the cache is
18531853cleared.
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-
18631855This 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-
18971879The above example assumes that the *station_id * never changes. If the
18981880relevant instance attributes are mutable, the *cached_property * approach
18991881can't be made to work because it cannot detect changes to the
0 commit comments