- **status**: in-progress --> review - **Comment**: db/8314 (branched off of [#8311] since it adds a requirement)
I looked into many off-the-shelf existing libraries but none worked: * `@methodtools.lru_cache()` is supposed to be exactly for this case of a method, but in my testing holds global cache still. Also has 3 more dependencies it pulls in. * `@cachedtools.cached(cache={})` holds global cache * `@cachedtools.cached(cache=WeakValueDictionary())` errors * `@cachedtools.cachedmethod(lambda self: self.cache, key=partial(hashkey, 'our_method_name'))` requires a self.cache (or creating one on the fly) and knowing the method name to make a properly scoped key * `@pylru.lrudecorator()` requires size param, holds global cache * `@ring.lru()` ran into UnicodeEncodeError * `@memoized_method` from https://stackoverflow.com/a/33672499/ gets interference with Ming since it rewrites the attr Drop-ins for py3 `functools.lru_cache` (which wouldn't work either): * `@cachedtools.lru_cache()` errors * `@repoze.lru.lru_cache()` requires size param, holds global cache * `@functools32.lru_cache()` holds global cache * `@backports.functools_lru_cache` holds global cache --- ** [tickets:#8314] @memoize on methods should still allow garbage collection** **Status:** review **Milestone:** unreleased **Created:** Wed Jul 03, 2019 08:14 PM UTC by Dave Brondsema **Last Updated:** Wed Jul 03, 2019 08:14 PM UTC **Owner:** Dave Brondsema Our `@memoize` works pretty similarly to `@lru_cache` and doesn't do what you might expect on a method (as opposed to a simple function). It creates a global class-level cache with `self` as one of the args and thus the `self` object is referenced forever and cannot be garbage collected. https://bugs.python.org/issue19859 describes the situation --- Sent from forge-allura.apache.org because dev@allura.apache.org is subscribed to https://forge-allura.apache.org/p/allura/tickets/ To unsubscribe from further messages, a project admin can change settings at https://forge-allura.apache.org/p/allura/admin/tickets/options. Or, if this is a mailing list, you can unsubscribe from the mailing list.