core.cache.instance_cache

Attributes

_F

Functions

instance_lru_cache(…)

Least-recently-used cache decorator for class methods.

Module Contents

core.cache.instance_cache._F[source]
core.cache.instance_cache.instance_lru_cache(*, maxsize: int | None = ...) collections.abc.Callable[[_F], _F][source]
core.cache.instance_cache.instance_lru_cache(method: _F, *, maxsize: int | None = ...) _F

Least-recently-used cache decorator for class methods.

The cache follows the lifetime of an object (it is stored on the object, not on the class) and can be used on unhashable objects.

This is a wrapper around functools.lru_cache which prevents memory leaks when using LRU cache within classes.

https://stackoverflow.com/a/71663059