mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-17 19:15:55 +08:00
A small speed optimization that helps a lot with sys.version_info >= (3, 0) patterns in typeshed
This commit is contained in:
@@ -35,7 +35,7 @@ from jedi.evaluate.utils import safe_property, to_list
|
|||||||
from jedi.evaluate.cache import evaluator_method_cache
|
from jedi.evaluate.cache import evaluator_method_cache
|
||||||
from jedi.evaluate.filters import ParserTreeFilter, LazyAttributeOverwrite, \
|
from jedi.evaluate.filters import ParserTreeFilter, LazyAttributeOverwrite, \
|
||||||
publish_method
|
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
|
TreeContext, ContextualizedNode, iterate_contexts, HelperContextMixin
|
||||||
from jedi.parser_utils import get_sync_comp_fors
|
from jedi.parser_utils import get_sync_comp_fors
|
||||||
|
|
||||||
@@ -44,6 +44,14 @@ class IterableMixin(object):
|
|||||||
def py__stop_iteration_returns(self):
|
def py__stop_iteration_returns(self):
|
||||||
return ContextSet([compiled.builtin_from_name(self.evaluator, u'None')])
|
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):
|
class GeneratorBase(LazyAttributeOverwrite, IterableMixin):
|
||||||
array_type = None
|
array_type = None
|
||||||
|
|||||||
Reference in New Issue
Block a user