-
-
Notifications
You must be signed in to change notification settings - Fork 32.7k
Closed as not planned
Labels
interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)performancePerformance or resource usagePerformance or resource usagetype-featureA feature request or enhancementA feature request or enhancement
Description
Feature or enhancement
Proposal:
suppose the following code
1 in [1, 2]
it produces such byte code
0 0 RESUME 0
1 2 LOAD_CONST 0 (1)
4 LOAD_CONST 1 ((1, 2))
6 CONTAINS_OP 0
8 RETURN_VALUE
however, interpreter can easily fold such an expression to a constant in the ast_opt stage. This only applies if both ast nodes are Constant_kind
. But there is one obstacle. Types are not yet ready and have incomplete mro at the ast_opt stage. So we can't use functions like PyObject_RichCompare
for this. We can compare pointers to PyObject instead, since we know that each object in a "constant expression" is internally a singleton (interned strings, integers from -5 to 255, etc.). Thus, for them, the ==
operator is semantically equal to the is
operator. I'm going to make pull request for this
Has this already been discussed elsewhere?
No response given
Links to previous discussion of this feature:
No response
Linked PRs
Eclips4
Metadata
Metadata
Assignees
Labels
interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)performancePerformance or resource usagePerformance or resource usagetype-featureA feature request or enhancementA feature request or enhancement