Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

made the module with cursor parser lazy

  • Loading branch information...
commit 65e1b372b698636716518143a6827253f0c2c644 1 parent 4519221
@davidhalter authored
Showing with 16 additions and 10 deletions.
  1. +16 −10 jedi/modules.py
View
26 jedi/modules.py
@@ -54,16 +54,22 @@ def __init__(self, path, source, position):
self.source = source
- try:
- del builtin.CachedModule.cache[self.path]
- except KeyError:
- pass
- # Call the parser already here, because it will be used anyways.
- # Also, the position is here important (which will not be used by
- # default), therefore fill the cache here.
- self._parser = parsing.PyFuzzyParser(source, path, position)
- if self.path:
- builtin.CachedModule.cache[self.path] = time.time(), self._parser
+ @property
+ def parser(self):
+ """ get the parser lazy """
+ if not self._parser:
+ try:
+ del builtin.CachedModule.cache[self.path]
+ except KeyError:
+ pass
+ # Call the parser already here, because it will be used anyways.
+ # Also, the position is here important (which will not be used by
+ # default), therefore fill the cache here.
+ self._parser = parsing.PyFuzzyParser(self.source, self.path,
+ self.position)
+ if self.path:
+ builtin.CachedModule.cache[self.path] = time.time(), self._parser
+ return self._parser
def get_path_until_cursor(self):
""" Get the path under the cursor. """
Please sign in to comment.
Something went wrong with that request. Please try again.