Missing some obvious ast optimizations #123080
Labels
interpreter-core
(Objects, Python, Grammar, and Parser dirs)
performance
Performance or resource usage
type-feature
A feature request or enhancement
Uh oh!
There was an error while loading. Please reload this page.
Feature or enhancement
Proposal:
suppose the following code
it produces such byte code
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 likePyObject_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 theis
operator. I'm going to make pull request for thisHas this already been discussed elsewhere?
No response given
Links to previous discussion of this feature:
No response
Linked PRs
The text was updated successfully, but these errors were encountered: