[issue28813] Remove unneeded folded consts after peephole

Raymond Hettinger report at bugs.python.org
Sun Nov 27 13:09:45 EST 2016


Raymond Hettinger added the comment:

FWIW, we intentionally decided not to do this when constant folding was added.  The idea was to keep the peephole optimizer simple and to have it do the minimum work necessary to get its job done (optimizing the constants table takes extra time to do but doesn't result in faster code).  

Another reason was that aside from contrived examples (such as the OP's example), very little real-world code gets any benefit and the benefit tends to be very small.  (In other words, no one will actually notice or benefit from this patch, but their compilation times will all slow down slightly).

Lastly, the intention is to stop building out constant folding.  The correct place for constant folding is upstream, using AST prior to code generation.

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

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue28813>
_______________________________________


More information about the Python-bugs-list mailing list