kyrenia kyrenia - 1 year ago 145
Python Question

Reset the cache in lru_cache

Is there any way of over-riding the

in python?

Specifically if I have a function such as:

import functools

def function_of_interest(variables):


Is is possible to reset the cache, and hence run-run the function?

Answer Source

Is is possible to reset the cache, and hence re-run the function?

If my understanding is correct, you can just use cache_clear on the decorated function. If you've filled the cache by running it, this clears all indicators for you, that is:


Should result in a cache_info of:

CacheInfo(hits=0, misses=0, maxsize=None, currsize=0)
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download