Open kosack opened 2 days ago
lrc_cache
, at least in the past, didn't play nice with class methods.
The cache was global, not per instance.
https://docs.python.org/3/faq/programming.html#faq-cache-method-calls
seems to be supported now.
But:
The advantage of the least recently used algorithm is that the cache is bounded by the specified maxsize. The disadvantage is that instances are kept alive until they age out of the cache or until the cache is cleared.
https://github.com/cta-observatory/ctapipe/blob/b63a7d4de5d65520cdf721d8b56b8990e43c2673/src/ctapipe/instrument/camera/geometry.py#L934-L935
The hand-crafted border pixel caching could just use the
@functools.lru_cache
or@functools.cache
decorator. Is there a reason not to?