This repository provides a Python decorator @cached_method
that caches method results similar to functools.lru_cache
, but with each instance having its own cache.
The cached_method
decorator allows you to cache the results of an instance method call so that subsequent calls with the same arguments will return the cached result instead of performing the computation again.
This decorator provides two key benefits:
- The cache is cleared when the instance is garbage collected (by using weak references).