Message82800
> 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 |
|
Date |
User |
Action |
Args |
2009-02-27 01:09:38 | vstinner | set | recipients:
+ vstinner, theller, debedb |
2009-02-27 01:09:38 | vstinner | set | messageid: <1235696978.11.0.281841880228.issue5377@psf.upfronthosting.co.za> |
2009-02-27 01:09:36 | vstinner | link | issue5377 messages |
2009-02-27 01:09:35 | vstinner | create | |
|