int vs long
Peter Otten
__peter__ at web.de
Mon Jun 4 04:50:14 EDT 2007
Marc 'BlackJack' Rintsch wrote:
> In <f40fki$p9p$00$1 at news.t-online.com>, Peter Otten wrote:
>
>> Marc 'BlackJack' Rintsch wrote:
>>
>>>>>> from itertools import count
>>>>>> from sys import maxint
>>>>>> c = count(maxint)
>>>>>> c.next()
>>> 2147483647
>>>>>> c.next()
>>> -2147483648
>>>
>>> What I find most disturbing here, is that it happens silently. I would
>>> have expected an exception instead of the surprise.
>>
>> This is fixed in Python2.5:
>>
>>>>> from itertools import count
>>>>> import sys
>>>>> c = count(sys.maxint)
>>>>> c.next(), c.next()
>> (2147483647, 2147483648L)
>
> Hm, my test above was from 2.5!?
Then your installation is broken. What does
>>> import itertools
>>> itertools
<module 'itertools' from
'/usr/local/lib/python2.5/lib-dynload/itertools.so'>
print?
By the way, here's what I get if I force the wrong library upon python2.5:
/usr/local/lib/python2.4/lib-dynload $ python2.5
Python 2.5 (r25:51908, Oct 3 2006, 08:48:09)
[GCC 3.3.3 (SuSE Linux)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
sys:1: RuntimeWarning: Python C API version mismatch for module readline:
This Python has API version 1013, module readline has version 1012.
>>> import itertools
__main__:1: RuntimeWarning: Python C API version mismatch for module
itertools: This Python has API version 1013, module itertools has version
1012.
>>> itertools
<module 'itertools' from 'itertools.so'>
>>> import sys
>>> c = itertools.count(sys.maxint)
>>> c.next(), c.next()
(2147483647, -2147483648)
Peter
More information about the Python-list
mailing list