STINNER Victor <victor.stin...@haypocalc.com> added the comment: > the question is why would the second int() return an int, > if it's indeed a long?
Python doesn't convert long to int even if the long can fit in an int. Example: >>> type(1) <type 'int'> >>> type(1L) <type 'long'> >>> type(1L+1) <type 'long'> >>> type(2) <type 'int'> Even if 1L and 2L can fit in a int, Python keeps the long type. > why the difference in this behavior between 2.5.1 and 2.5.2 No idea. You can simplify your test script with : # example with python 2.5.1 (32 bits CPU) >>> type(-int('2147483648')) <type 'long'> >>> sys.maxint On a 64 bits CPU, sys.maxint is much bigger, so don't have the problem with -2147483648 but with -9223372036854775808: # example with python 2.5.2 (*64 bits CPU*) >>> sys.maxint + 1 9223372036854775808L >>> -int('9223372036854775808') -9223372036854775808L >>> int(-int('9223372036854775808')) -9223372036854775808 _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue5377> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com