diff --git a/jedi/evaluate/context/iterable.py b/jedi/evaluate/context/iterable.py index 91b6f54d..56927f8f 100644 --- a/jedi/evaluate/context/iterable.py +++ b/jedi/evaluate/context/iterable.py @@ -35,7 +35,7 @@ from jedi.evaluate.utils import safe_property, to_list from jedi.evaluate.cache import evaluator_method_cache from jedi.evaluate.filters import ParserTreeFilter, LazyAttributeOverwrite, \ publish_method -from jedi.evaluate.base_context import ContextSet, NO_CONTEXTS, \ +from jedi.evaluate.base_context import ContextSet, Context, NO_CONTEXTS, \ TreeContext, ContextualizedNode, iterate_contexts, HelperContextMixin from jedi.parser_utils import get_sync_comp_fors @@ -44,6 +44,14 @@ class IterableMixin(object): def py__stop_iteration_returns(self): return ContextSet([compiled.builtin_from_name(self.evaluator, u'None')]) + # At the moment, safe values are simple values like "foo", 1 and not + # lists/dicts. Therefore as a small speed optimization we can just do the + # default instead of resolving the lazy wrapped contexts, that are just + # doing this in the end as well. + # This mostly speeds up patterns like `sys.version_info >= (3, 0)` in + # typeshed. + get_safe_value = Context.get_safe_value + class GeneratorBase(LazyAttributeOverwrite, IterableMixin): array_type = None