[issue9011] ast_for_factor unary minus optimization changes AST
Mark Dickinson
report at bugs.python.org
Thu Jun 17 13:16:01 CEST 2010
Mark Dickinson <dickinsm at gmail.com> added the comment:
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?
----------
nosy: +nascheme
priority: normal -> high
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue9011>
_______________________________________
More information about the Python-bugs-list
mailing list