This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author vstinner
Recipients debedb, theller, vstinner
Date 2009-02-27.01:09:34
SpamBayes Score 1.3111767e-07
Marked as misclassified No
Message-id <1235696978.11.0.281841880228.issue5377@psf.upfronthosting.co.za>
In-reply-to
Content
> 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
History
Date User Action Args
2009-02-27 01:09:38vstinnersetrecipients: + vstinner, theller, debedb
2009-02-27 01:09:38vstinnersetmessageid: <1235696978.11.0.281841880228.issue5377@psf.upfronthosting.co.za>
2009-02-27 01:09:36vstinnerlinkissue5377 messages
2009-02-27 01:09:35vstinnercreate