Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

faster get_in_function_call, may improve #34

  • Loading branch information...
commit 3474d481b61694f99c5c2ee208a6a8198fbff8e9 1 parent cfaff62
@davidhalter authored
Showing with 26 additions and 3 deletions.
  1. +3 −1 jedi/api.py
  2. +16 −1 jedi/helpers.py
  3. +7 −1 jedi/settings.py
View
4 jedi/api.py
@@ -349,7 +349,9 @@ def check_cache():
if call is None:
return None
- origins = evaluate.follow_call(call)
+ with helpers.scale_speed_settings(settings.scale_get_in_function_call):
+ origins = evaluate.follow_call(call)
+ print settings.max_executions, helpers.ExecutionRecursionDecorator.execution_count
if len(origins) == 0:
return None
View
17 jedi/helpers.py
@@ -1,5 +1,6 @@
import copy
import weakref
+import contextlib
import parsing
import evaluate
@@ -117,6 +118,9 @@ def check_recursion(cls, execution, evaluate_generator):
cls.execution_funcs.add(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)):
return False
module = execution.get_parent_until()
@@ -129,7 +133,7 @@ def check_recursion(cls, execution, evaluate_generator):
if in_execution_funcs and \
len(cls.execution_funcs) > settings.max_until_execution_unique:
return True
- if cls.execution_count > settings.max_executions:
+ if cls.execution_count > settings.max_executions_without_builtins:
return True
return False
@@ -249,3 +253,14 @@ def check_arr_index():
# The third return is just necessary for recursion inside, because
# it needs to know when to stop iterating.
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
View
8 jedi/settings.py
@@ -61,7 +61,13 @@
max_function_recursion_level = 5
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
Please sign in to comment.
Something went wrong with that request. Please try again.