functools.cache, when applied to a method, caches the self argument. This can also keep the instance alive long after it is no longer needed. See for example this discussion.
Following the same API as singledispatch and singledispatchmethod, we should consider adding a cachemethod decorator that either avoids caching self, or uses a weakref for it.
Linked PRs
functools.cache, when applied to a method, caches theselfargument. This can also keep the instance alive long after it is no longer needed. See for example this discussion.Following the same API as
singledispatchandsingledispatchmethod, we should consider adding acachemethoddecorator that either avoids cachingself, or uses a weakref for it.Linked PRs
functools.cached_methoddecorator #150002