[issue21074] Too aggressive constant folding
eryksun
report at bugs.python.org
Thu Mar 27 06:04:04 CET 2014
eryksun added the comment:
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.
----------
nosy: +eryksun
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue21074>
_______________________________________
More information about the Python-bugs-list
mailing list