1
0
forked from VimPlug/jedi

Use the memoize function for faked arguments only when needed.

It's important to note that memoizing every object would mean that
theoretically all objects passed through get_faked would get memoized. This
would have been a possible memory leak, which we should avoid.
Obviously the previous solution proposed in #649 was still better, but this
issue was a new one. Also using str() around keys was not a good idea.

Refs #649.
This commit is contained in:
Dave Halter
2016-07-31 15:02:30 +02:00
parent 7b58ffcfd1
commit 6f598b1157
3 changed files with 50 additions and 30 deletions

View File

@@ -91,18 +91,6 @@ 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):