forked from VimPlug/jedi
Cache default environment
This commit is contained in:
@@ -14,7 +14,7 @@ from collections import namedtuple
|
|||||||
from distutils.spawn import find_executable
|
from distutils.spawn import find_executable
|
||||||
|
|
||||||
from jedi._compatibility import GeneralizedPopen
|
from jedi._compatibility import GeneralizedPopen
|
||||||
from jedi.cache import memoize_method
|
from jedi.cache import memoize_method, time_cache
|
||||||
from jedi.evaluate.compiled.subprocess import get_subprocess, \
|
from jedi.evaluate.compiled.subprocess import get_subprocess, \
|
||||||
EvaluatorSameProcess, EvaluatorSubprocess
|
EvaluatorSameProcess, EvaluatorSubprocess
|
||||||
|
|
||||||
@@ -170,6 +170,11 @@ def get_default_environment():
|
|||||||
return SameEnvironment()
|
return SameEnvironment()
|
||||||
|
|
||||||
|
|
||||||
|
@time_cache("_default_environment_validity")
|
||||||
|
def get_cached_default_environment():
|
||||||
|
return get_default_environment()
|
||||||
|
|
||||||
|
|
||||||
def find_virtualenvs(paths=None, **kwargs):
|
def find_virtualenvs(paths=None, **kwargs):
|
||||||
"""
|
"""
|
||||||
:param paths: A list of paths in your file system to be scanned for
|
:param paths: A list of paths in your file system to be scanned for
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import json
|
|||||||
|
|
||||||
from jedi._compatibility import FileNotFoundError, NotADirectoryError
|
from jedi._compatibility import FileNotFoundError, NotADirectoryError
|
||||||
from jedi.api.environment import SameEnvironment, \
|
from jedi.api.environment import SameEnvironment, \
|
||||||
get_default_environment
|
get_cached_default_environment
|
||||||
from jedi.api.exceptions import WrongVersion
|
from jedi.api.exceptions import WrongVersion
|
||||||
from jedi._compatibility import force_unicode
|
from jedi._compatibility import force_unicode
|
||||||
from jedi.evaluate.sys_path import discover_buildout_paths
|
from jedi.evaluate.sys_path import discover_buildout_paths
|
||||||
@@ -136,7 +136,7 @@ class Project(object):
|
|||||||
|
|
||||||
def get_environment(self):
|
def get_environment(self):
|
||||||
if self._environment is None:
|
if self._environment is None:
|
||||||
return get_default_environment()
|
return get_cached_default_environment()
|
||||||
|
|
||||||
return self._environment
|
return self._environment
|
||||||
|
|
||||||
|
|||||||
@@ -161,3 +161,5 @@ call_signatures_validity = 3.0
|
|||||||
Finding function calls might be slow (0.1-0.5s). This is not acceptible for
|
Finding function calls might be slow (0.1-0.5s). This is not acceptible for
|
||||||
normal writing. Therefore cache it for a short time.
|
normal writing. Therefore cache it for a short time.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
_default_environment_validity = 10 * 60 # 0 Minutes
|
||||||
|
|||||||
Reference in New Issue
Block a user