forked from VimPlug/jedi
faster get_in_function_call, may improve #34
This commit is contained in:
@@ -349,7 +349,9 @@ class Script(object):
|
|||||||
if call is None:
|
if call is None:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
with helpers.scale_speed_settings(settings.scale_get_in_function_call):
|
||||||
origins = evaluate.follow_call(call)
|
origins = evaluate.follow_call(call)
|
||||||
|
print settings.max_executions, helpers.ExecutionRecursionDecorator.execution_count
|
||||||
|
|
||||||
if len(origins) == 0:
|
if len(origins) == 0:
|
||||||
return None
|
return None
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import copy
|
import copy
|
||||||
import weakref
|
import weakref
|
||||||
|
import contextlib
|
||||||
|
|
||||||
import parsing
|
import parsing
|
||||||
import evaluate
|
import evaluate
|
||||||
@@ -117,6 +118,9 @@ class ExecutionRecursionDecorator(object):
|
|||||||
cls.execution_funcs.add(execution.base)
|
cls.execution_funcs.add(execution.base)
|
||||||
cls.parent_execution_funcs.append(execution.base)
|
cls.parent_execution_funcs.append(execution.base)
|
||||||
|
|
||||||
|
if cls.execution_count > settings.max_executions:
|
||||||
|
return True
|
||||||
|
|
||||||
if isinstance(execution.base, (evaluate.Generator, evaluate.Array)):
|
if isinstance(execution.base, (evaluate.Generator, evaluate.Array)):
|
||||||
return False
|
return False
|
||||||
module = execution.get_parent_until()
|
module = execution.get_parent_until()
|
||||||
@@ -129,7 +133,7 @@ class ExecutionRecursionDecorator(object):
|
|||||||
if in_execution_funcs and \
|
if in_execution_funcs and \
|
||||||
len(cls.execution_funcs) > settings.max_until_execution_unique:
|
len(cls.execution_funcs) > settings.max_until_execution_unique:
|
||||||
return True
|
return True
|
||||||
if cls.execution_count > settings.max_executions:
|
if cls.execution_count > settings.max_executions_without_builtins:
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@@ -249,3 +253,14 @@ def scan_array_for_pos(arr, pos):
|
|||||||
# The third return is just necessary for recursion inside, because
|
# The third return is just necessary for recursion inside, because
|
||||||
# it needs to know when to stop iterating.
|
# it needs to know when to stop iterating.
|
||||||
return call, check_arr_index(), stop
|
return call, check_arr_index(), stop
|
||||||
|
|
||||||
|
|
||||||
|
@contextlib.contextmanager
|
||||||
|
def scale_speed_settings(factor):
|
||||||
|
a = settings.max_executions
|
||||||
|
b = settings.max_until_execution_unique
|
||||||
|
settings.max_executions *= factor
|
||||||
|
settings.max_until_execution_unique *= factor
|
||||||
|
yield
|
||||||
|
settings.max_executions = a
|
||||||
|
settings.max_until_execution_unique = b
|
||||||
|
|||||||
@@ -61,7 +61,13 @@ additional_dynamic_modules = []
|
|||||||
|
|
||||||
max_function_recursion_level = 5
|
max_function_recursion_level = 5
|
||||||
max_until_execution_unique = 50
|
max_until_execution_unique = 50
|
||||||
max_executions = 1000
|
max_executions_without_builtins = 200
|
||||||
|
max_executions = 250
|
||||||
|
|
||||||
|
# Because get_in_function_call is normally used on every single key hit, it has
|
||||||
|
# to be faster than a normal completion. This is the factor that is used to
|
||||||
|
# scale `max_executions` and `max_until_execution_unique`:
|
||||||
|
scale_get_in_function_call = 0.1
|
||||||
|
|
||||||
# ----------------
|
# ----------------
|
||||||
# various
|
# various
|
||||||
|
|||||||
Reference in New Issue
Block a user