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 eryksun
Recipients benjamin.peterson, eryksun, methane, vstinner
Date 2014-03-27.05:04:04
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1395896644.83.0.0127546834957.issue21074@psf.upfronthosting.co.za>
In-reply-to
Content
The redesigned peephole optimizer in PY3 improves constant folding. Limiting this would be a step back. Plus you can get the same behavior in PY2 if you first expand the power. For example:

    # using 2**30, for a 32-bit process

    def uncalled():
        x = b'x' * 1073741824

At issue is the design of fold_binops_on_constants in peephole.c:

http://hg.python.org/cpython/file/04f714765c13/Python/peephole.c#l138

Some LBYL may be helpful here. It could get the size and integer value of the two objects before evaluating the switch statement. Then use these values to skip certain operations, such as skipping PyNumber_Multiply in the case of BINARY_MULTIPLY.
History
Date User Action Args
2014-03-27 05:04:04eryksunsetrecipients: + eryksun, vstinner, benjamin.peterson, methane
2014-03-27 05:04:04eryksunsetmessageid: <1395896644.83.0.0127546834957.issue21074@psf.upfronthosting.co.za>
2014-03-27 05:04:04eryksunlinkissue21074 messages
2014-03-27 05:04:04eryksuncreate