You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
lru_cache introduces a correctness problem for methods or properties whose output depend on attributes stored in self.
Of course you can manually call clear_cache, but
this is a leaky abstraction
this method is highly inaccessible for properties
Here i explore how the cache behaves, along with my suggested solution:
lru_cache
introduces a correctness problem for methods or properties whose output depend on attributes stored inself
.Of course you can manually call
clear_cache
, butHere i explore how the cache behaves, along with my suggested solution:
problem exploration
output
My suggested solution is an optional mixin class, that can be added as a parent class:
It clears all caches each time you write to an attribute stored in the class.
Although a pessimistic approach, it does work.
Do you want a PR? Comments?
The text was updated successfully, but these errors were encountered: