1
0
forked from VimPlug/jedi

Remove underscore_memoization caching method

This commit is contained in:
Dave Halter
2020-01-25 17:29:52 +01:00
parent 235b887b75
commit 8bde54a072
3 changed files with 7 additions and 48 deletions

View File

@@ -20,38 +20,6 @@ from parso.cache import parser_cache
_time_caches = {}
def underscore_memoization(func):
"""
Decorator for methods::
class A(object):
def x(self):
if self._x:
self._x = 10
return self._x
Becomes::
class A(object):
@underscore_memoization
def x(self):
return 10
A now has an attribute ``_x`` written by this decorator.
"""
name = '_' + func.__name__
def wrapper(self):
try:
return getattr(self, name)
except AttributeError:
result = func(self)
setattr(self, name, result)
return result
return wrapper
def clear_time_caches(delete_all=False):
""" Jedi caches many things, that should be completed after each completion
finishes.