This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author rhettinger
Recipients Adrian Wielgosik, rhettinger, serhiy.storchaka
Date 2016-11-27.18:09:45
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1480270185.86.0.345388371109.issue28813@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2016-11-27 18:09:45rhettingersetrecipients: + rhettinger, serhiy.storchaka, Adrian Wielgosik
2016-11-27 18:09:45rhettingersetmessageid: <1480270185.86.0.345388371109.issue28813@psf.upfronthosting.co.za>
2016-11-27 18:09:45rhettingerlinkissue28813 messages
2016-11-27 18:09:45rhettingercreate