[issue2499] Fold unary + and not on constants

Raymond Hettinger report at bugs.python.org
Fri Mar 28 08:25:25 CET 2008


Raymond Hettinger <rhettinger at users.sourceforge.net> added the comment:

It would be helpful if we talked before going further on build-outs to 
the peephole optimizer.  IIRC, we chose to not do this one because it 
interfered with other more important optimizations.

More importantly, we decided that the peepholer is the wrong place to 
do much of this work.  Most of the peepholer is going to be migrated 
up the chain, after the AST is generated, but before the opcodes are 
generated.  That is a faster, more reliable, and more general 
approach. 

The constant folding anti-duplication patch should also not be done 
for this same reason.  That patch slows down compilation and makes it 
more fragile but does not add speed (just like the dead code 
elimination patches).  When the peepholer is moved-up, the anti-
duplication code won't be needed (as you won't need its attendant 
rescan/rewrite pass of the bytecode).

You're writing these faster than I have time to review and likely 
reject them.  Please show some moderation.  The peepholer is 
intentionally very conservative.

----------
nosy: +rhettinger

__________________________________
Tracker <report at bugs.python.org>
<http://bugs.python.org/issue2499>
__________________________________


More information about the Python-bugs-list mailing list