Raymond Hettinger <rhettin...@users.sourceforge.net> added the comment:

I'm disinclined to accept this patch.  There is only minor space savings and no 
actual speed-up.

When constant folding was introduced, a design decision was made to ignore the 
issue of orphan constants.  The rationale behind that decision still stands.

The peepholer has aspired to be very conservative and is considered a high-risk 
area for changes.  Since its introduction, Guido has constantly teetered on the 
edge of entirely ripping out the peepholer.  Right now, the stability of that 
code is its greatest asset and we should be reluctant to modify it.

Also, the peephole optimizer was developed before the AST branch was added to 
Python.  Constant folding more properly belongs at the AST level, not in the 
peepholer itself.  Our strategy is to move as much as possible into an AST 
optimizer and to stop building out the peephole optimizer.

Right now, the pattern is tokenize -> parse -> AST -> genbytecode -> peephole 
optimization (which disassembles the bytecode, analyzed it and rewrites it) -> 
final bytecode.   The correct pattern is tokenize -> parse -> AST -> optimize 
-> genbytecode -> peephole optimization with minimal disassembly, analysis, and 
opcode rewrites -> final bytecode.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue11462>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to