cachemethod#
- gammapy.utils.cache.cachemethod(fn)[source]#
Decorator to cache method results on a per-instance basis using weak references.
This decorator stores cached results of method calls in a
WeakKeyDictionary
, ensuring that the cache is automatically cleared when the instance is garbage collected. The cache key is generated usingmake_key
, which normalizes and hashes the method arguments to ensure consistent and order-independent caching.- Parameters:
- fncallable
The method to be decorated.
- Returns:
- wrappercallable
The wrapped method with caching behavior.