I have this simple cache
decorator demo here
@functools.cache
def cached_fib(n):
assert n > 0
if n <= 2:
return 1
return cached_fib(n - 1) + cached_fib(n - 2)
t1 = time.perf_counter()
cached_fib(400)
t2 = time.perf_counter()
print(f"cached_fib: {t2 - t1}") # 0.0004117000003134308
I want to access the actual cache dictionary object inside this cached_fib
, but when I try to access through cached_fib.cache
, it gives me an error saying that AttributeError: 'functools._lru_cache_wrapper' object has no attribute 'cache'
though the cache attribute is used in python and c version alike.
Thank you!