N.B. That if block isn't pure optimization: removing it gives a minor change in behaviour:
Currently (Python 2.7, on a 64-bit machine):
>>> -9223372036854775808
-9223372036854775808
And with the optimization removed:
>>> -9223372036854775808
-9223372036854775808L
I actually consider the second behaviour more correct than the first, since it follows clearly from the language rules (numeric literals have no sign, so the above *should* be interpreted as the unary minus operator applied to a literal, and that literal really is a PyLong). But obviously the contributors to issue 1441486 either disagree, or didn't want to introduce a regression from 2.4.
I still consider that removing that if block is the right thing to do for 2.7. The change in behaviour really shouldn't affect any reasonable code---anywhere that an int is acceptable, a long should be too.
Neil, any comments? |