If you run >>> dis.dis(lambda: 99**1000003) and press Ctrl-C immediately, you'll see the numbers without constant folding: 1 0 LOAD_CONST 1 (99) 3 LOAD_CONST 2 (1000003) 6 BINARY_POWER 7 RETURN_VALUE If you wait long enough instead (don't press Ctrl-C), you'll see a very big number. It seems strange to do two different things. Perhaps the KeyboardInterrupt should be rethrown instead?
> Probably due to the fact that the peepholer > avoids constant folding when any exception happens. Yes. And that is a feature, not a bug. It would better though if the keyboard interrupt was not swallowed.
2010/4/14 Raymond Hettinger <report@bugs.python.org>: > > Raymond Hettinger <rhettinger@users.sourceforge.net> added the comment: > >> Probably due to the fact that the peepholer >> avoids constant folding when any exception happens. > > Yes. And that is a feature, not a bug. > > It would better though if the keyboard interrupt was not swallowed. Agreed on both points.