From a3c04fc140c7e708c9240fe3c246a0bb333cda03 Mon Sep 17 00:00:00 2001 From: Sergei Trofimov Date: Wed, 14 Nov 2018 13:30:07 +0000 Subject: [PATCH] utils/misc: document memoized limitation Document the issue with using memoized with mutable types. --- devlib/utils/misc.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/devlib/utils/misc.py b/devlib/utils/misc.py index 45d19d2..208e177 100644 --- a/devlib/utils/misc.py +++ b/devlib/utils/misc.py @@ -648,7 +648,15 @@ def __get_memo_id(obj): @wrapt.decorator def memoized(wrapped, instance, args, kwargs): # pylint: disable=unused-argument - """A decorator for memoizing functions and methods.""" + """ + A decorator for memoizing functions and methods. + + .. warning:: this may not detect changes to mutable types. As long as the + memoized function was used with an object as an argument + before, the cached result will be returned, even if the + structure of the object (e.g. a list) has changed in the mean time. + + """ func_id = repr(wrapped) def memoize_wrapper(*args, **kwargs):