From a77d968bbdd81867cf4d42573f2893a349d9d37b Mon Sep 17 00:00:00 2001 From: Paul McCarthy <pauld.mccarthy@gmail.com> Date: Fri, 2 Dec 2016 12:20:52 +0000 Subject: [PATCH] Removed some lies from function documentation. --- fsl/utils/memoize.py | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/fsl/utils/memoize.py b/fsl/utils/memoize.py index 0a51b446e..6fe330ebb 100644 --- a/fsl/utils/memoize.py +++ b/fsl/utils/memoize.py @@ -28,17 +28,10 @@ log = logging.getLogger(__name__) # TODO Make this a class, and add # a "clearCache" method to it. def memoize(func): - """Memoize the given function by the value of the input arguments, allowing - the caller to specify which positional arguments (by index) and keyword - arguments (by name) are used for the comparison. + """Memoize the given function by the value of the input arguments. - If no positional or keyword arguments are specified, the function is - memoized on all arguments. Note that the arguments used for memoization - must be hashable, as they are used as keys in a dictionary. - - - :arg args: A list of positional argument indices. - :arg kwargs: A list of keyword argument names. + Note that the arguments used for memoization must be hashable, as they are + used as keys in a dictionary. """ cache = {} @@ -62,6 +55,8 @@ def memoize(func): try: result = cache[key] + log.debug('Retrieved from cache[{}]: {}'.format(key, result)) + except KeyError: result = func(*a, **kwa) @@ -111,8 +106,8 @@ def memoizeMD5(func): def skipUnchanged(func): """This decorator is intended for use with *setter* functions - a function - which accepts a name and a value, and is intended to set some named - attribute to the given value. + which accepts a name and a value, and is intended to set some named + attribute to the given value. This decorator keeps a cache of name-value pairs. When the decorator is called with a specific name and value, the cache is checked and, if the -- GitLab