Update for an Issue #352

This commit is contained in:
Miroslav Stampar
2013-01-30 10:38:11 +01:00
parent bd08ede117
commit d6fb0e8545
2 changed files with 98 additions and 6 deletions

View File

@@ -11,9 +11,11 @@ def cachedmethod(f, cache={}):
Reference: http://code.activestate.com/recipes/325205-cache-decorator-in-python-24/
"""
def _(*args, **kwargs):
key = (f, tuple(args), frozenset(kwargs.items()))
if key not in cache:
cache[key] = f(*args, **kwargs)
return cache[key]
return _