forked from VimPlug/jedi
Add memoize_function to cache and use it in fake.get_faked
The previously added test should now pass. Fix #591
This commit is contained in:
@@ -163,6 +163,18 @@ def memoize_method(method):
|
||||
return wrapper
|
||||
|
||||
|
||||
def memoize_function(obj):
|
||||
""" A normal memoize function for memoizing free functions. """
|
||||
cache = obj.cache = {}
|
||||
|
||||
def memoizer(*args, **kwargs):
|
||||
key = str(args) + str(kwargs)
|
||||
if key not in cache:
|
||||
cache[key] = obj(*args, **kwargs)
|
||||
return cache[key]
|
||||
return memoizer
|
||||
|
||||
|
||||
def cache_star_import(func):
|
||||
@time_cache("star_import_cache_validity")
|
||||
def wrapper(self):
|
||||
|
||||
Reference in New Issue
Block a user