[issue21074] Too aggressive constant folding

Steve Holden report at bugs.python.org
Fri Mar 28 09:18:19 CET 2014


Steve Holden added the comment:

Is a fix really required? Are we really supposed to protect programmers from their own folly by second-guessing when constant folding might be required and when it might not? How is hte interpreter supposed to know the function isn't called?

The simple solution to this problem is available in Python: simply declare a manifest constant and use that instead:

UNCALLED_SIZE = 2**32
def uncalled():
    x = b'x' * UNCALLED_SIZE

I'd recommend closing this issue (though I'm glad that people are concerned with optimization, I don't think that an optimizer should be too concerned with those rare cases when their optimization doesn't optimize.

But I'm not going to close it: wiser heads than mine are required.

----------
nosy: +holdenweb

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


More information about the Python-bugs-list mailing list