mirror of
https://github.com/powerline/powerline.git
synced 2025-07-15 09:54:54 +02:00
Don't use kwargs as part of the memoize key
This should be fixed later (if at all possible). Also see discussion at http://stackoverflow.com/questions/6407993/how-to-memoize-kwargs Refs #205.
This commit is contained in:
parent
d638f1d6ea
commit
e89e083fee
@ -16,10 +16,13 @@ class memoize(object):
|
|||||||
@wraps(func)
|
@wraps(func)
|
||||||
def decorated_function(*args, **kwargs):
|
def decorated_function(*args, **kwargs):
|
||||||
if self.additional_key:
|
if self.additional_key:
|
||||||
key = (func.__name__, args, tuple(kwargs.items()), self.additional_key(*args, **kwargs))
|
key = (func.__name__, args, self.additional_key(*args, **kwargs))
|
||||||
else:
|
else:
|
||||||
key = (func.__name__, args, tuple(kwargs.items()))
|
key = (func.__name__, args)
|
||||||
cached = self._cache.get(key, None)
|
try:
|
||||||
|
cached = self._cache.get(key, None)
|
||||||
|
except TypeError:
|
||||||
|
return func(*args, **kwargs)
|
||||||
if cached is None or time.time() - cached['time'] > self.timeout:
|
if cached is None or time.time() - cached['time'] > self.timeout:
|
||||||
cached = self._cache[key] = {
|
cached = self._cache[key] = {
|
||||||
'result': func(*args, **kwargs),
|
'result': func(*args, **kwargs),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user