Better update regarding 6acb2480b8

This commit is contained in:
stamparm 2013-02-22 10:49:45 +01:00
parent 44a46d2b10
commit 42cbd94fa4

View File

@ -13,7 +13,10 @@ def cachedmethod(f, cache={}):
"""
def _(*args, **kwargs):
key = (f, tuple(args), str(kwargs))
try:
key = (f, tuple(args), frozenset(kwargs.items()))
except:
key = "".join(str(_) for _ in (f, args, kwargs))
if key not in cache:
cache[key] = f(*args, **kwargs)
return cache[key]