From 16ad43922fd385621757d2d01ec222c8007fad35 Mon Sep 17 00:00:00 2001 From: Dave Halter Date: Tue, 5 Sep 2017 18:52:12 +0200 Subject: [PATCH] Aldo change CachedMetaClass a bit to use the same memoize decorator. --- jedi/evaluate/cache.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/jedi/evaluate/cache.py b/jedi/evaluate/cache.py index e3ceb503..fc6c30c4 100644 --- a/jedi/evaluate/cache.py +++ b/jedi/evaluate/cache.py @@ -19,6 +19,7 @@ def _memoize_default(default=_NO_DEFAULT, evaluator_is_first_arg=False, second_a """ def func(function): def wrapper(obj, *args, **kwargs): + # TODO These checks are kind of ugly and slow. if evaluator_is_first_arg: cache = obj.memoize_cache elif second_arg_is_evaluator: @@ -61,12 +62,19 @@ def evaluator_method_cache(default=_NO_DEFAULT): return decorator +def _memoize_meta_class(): + def decorator(call): + return _memoize_default(second_arg_is_evaluator=True)(call) + + return decorator + + class CachedMetaClass(type): """ This is basically almost the same than the decorator above, it just caches class initializations. Either you do it this way or with decorators, but with decorators you lose class access (isinstance, etc). """ - @_memoize_default(None, second_arg_is_evaluator=True) + @_memoize_meta_class() def __call__(self, *args, **kwargs): return super(CachedMetaClass, self).__call__(*args, **kwargs)