Skip to content

Comparison operators could benefit from constant folding #128706

@WolframAlph

Description

@WolframAlph

Feature or enhancement

Proposal:

Constant expresisons like:

1 + 1

are folded in AST optimizer, but constant comparisons are not. For instance:

1 in (1, 2)
3 > 2 > 1

etc...

Proposing to add constant comparison folding. Linking draft PR. No tests yet in case proposal is rejected. cc @Eclips4 as codeowner and AST specialist.

Has this already been discussed elsewhere?

No response given

Links to previous discussion of this feature:

No response

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    interpreter-core(Objects, Python, Grammar, and Parser dirs)performancePerformance or resource usagetype-featureA feature request or enhancement

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions