Skip to content
Snippets Groups Projects
Commit a77d968b authored by Paul McCarthy's avatar Paul McCarthy
Browse files

Removed some lies from function documentation.

parent 53962e78
No related branches found
No related tags found
No related merge requests found
Pipeline #
...@@ -28,17 +28,10 @@ log = logging.getLogger(__name__) ...@@ -28,17 +28,10 @@ log = logging.getLogger(__name__)
# TODO Make this a class, and add # TODO Make this a class, and add
# a "clearCache" method to it. # a "clearCache" method to it.
def memoize(func): def memoize(func):
"""Memoize the given function by the value of the input arguments, allowing """Memoize the given function by the value of the input arguments.
the caller to specify which positional arguments (by index) and keyword
arguments (by name) are used for the comparison.
If no positional or keyword arguments are specified, the function is Note that the arguments used for memoization must be hashable, as they are
memoized on all arguments. Note that the arguments used for memoization used as keys in a dictionary.
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.
""" """
cache = {} cache = {}
...@@ -62,6 +55,8 @@ def memoize(func): ...@@ -62,6 +55,8 @@ def memoize(func):
try: try:
result = cache[key] result = cache[key]
log.debug('Retrieved from cache[{}]: {}'.format(key, result))
except KeyError: except KeyError:
result = func(*a, **kwa) result = func(*a, **kwa)
...@@ -111,8 +106,8 @@ def memoizeMD5(func): ...@@ -111,8 +106,8 @@ def memoizeMD5(func):
def skipUnchanged(func): def skipUnchanged(func):
"""This decorator is intended for use with *setter* functions - a function """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 which accepts a name and a value, and is intended to set some named
attribute to the given value. attribute to the given value.
This decorator keeps a cache of name-value pairs. When the decorator is 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 called with a specific name and value, the cache is checked and, if the
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment