From d7aac2b5df29ad8bed5cac22aa9c7b590835cfcf Mon Sep 17 00:00:00 2001 From: Sergei Trofimov Date: Fri, 2 Sep 2016 13:22:09 +0100 Subject: [PATCH] utils: added a function to reset memoized cache Added a function to reset the memo cache used by memoized decorator, which would force all memoized functions to re-evalued their results when they are next called. This is primarily intended for debugging. --- devlib/utils/misc.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/devlib/utils/misc.py b/devlib/utils/misc.py index 0386982..95c93e1 100644 --- a/devlib/utils/misc.py +++ b/devlib/utils/misc.py @@ -537,6 +537,10 @@ def mask_to_list(mask): __memo_cache = {} +def reset_memo_cache(): + __memo_cache.clear() + + @wrapt.decorator def memoized(wrapped, instance, args, kwargs): """A decorator for memoizing functions and methods."""