New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fold unary + and not on constants #46751
Comments
Before: >>> dis(lambda:+2)
1 0 LOAD_CONST 0 (2)
3 UNARY_POSITIVE
4 RETURN_VALUE
>>> dis(lambda:not 2)
1 0 LOAD_CONST 0 (2)
3 UNARY_NOT
4 RETURN_VALUE After: >>> dis(lambda:+2)
1 0 LOAD_CONST 1 (2)
3 RETURN_VALUE
>>> dis(lambda:not 2)
1 0 LOAD_CONST 1 (False)
3 RETURN_VALUE |
It would be helpful if we talked before going further on build-outs to More importantly, we decided that the peepholer is the wrong place to The constant folding anti-duplication patch should also not be done You're writing these faster than I have time to review and likely |
On Fri, Mar 28, 2008 at 3:25 AM, Raymond Hettinger
Sure.
There are two optimization in my patch: one for + and the other Constant folding promotes more readable code: 24*60*60 is more obvious Here is another surprise with the current peepholer: 1 0 LOAD_CONST 0 (1) 1 0 LOAD_CONST 4 (7) I have a fix in the works, but I will wait for your further comments
I agree. Constant folding, is an interesting case because peepholer BTW, what is the rationale for leading +/- not being part of the What is the timeline for that project? Maybe a comment should be
ok :-) One more peephole optimizer related idea that I have in the |
Folding UNARY_POSITIVE was done by Raymond in r75601. |
Closing this. The Unary Positive is already implemented and there are |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: