3 ms·
Don't wrap instance methods with functools.lru_cache decorator in Python
- jepler 5y agoAh, I was puzzled by this at first too. What showed me the situation more clearly was clearing the cache _via the class object, not the instance_: >>> fnord = Fnord() >>> fnord.square(3) # lru_cache'd 9 >>> del fnord >>> Fnord.square.cache_clear() Collected a fnord