1
0
forked from VimPlug/jedi

some easier memoization for fast parser

This commit is contained in:
Dave Halter
2014-01-15 15:48:16 +01:00
parent d5aa36cc69
commit d71cdded6e
2 changed files with 39 additions and 27 deletions

View File

@@ -131,6 +131,19 @@ def underscore_memoization(func):
return wrapper
def underscore_none_memoization(func):
"""Like ``underscore_memoization`` just with None instead of exceptions."""
def wrapper(self):
name = '_' + func.__name__
value = getattr(self, name)
if value is None:
value = func(self)
setattr(self, name, value)
return value
return wrapper
def cache_star_import(func):
def wrapper(evaluator, scope, *args, **kwargs):
with common.ignored(KeyError):