Re: enumerate overflow

2007-10-04 Thread Gabriel Genellina
En Wed, 03 Oct 2007 08:46:31 -0300, <[EMAIL PROTECTED]> escribi�: > in python2.4, i read lines from a file with > > for lineNum, line in enumerate(f): ... > > However, lineNum soon overflows and starts counting backwards. How do > i force enumerate to return long integer? (what kind of files are

Re: enumerate overflow

2007-10-03 Thread Raymond Hettinger
On Oct 3, 12:52 pm, koara <[EMAIL PROTECTED]> wrote: > Thanks everybody for the reply and suggestions, I'm glad to see the > issues's already been discovered/discussed/almostresolved. The new code is checked-in. In Py2.6, enumerate() will no longer raise an OverflowError and it will automatically

Re: enumerate overflow

2007-10-03 Thread koara
On Oct 3, 7:22 pm, Raymond Hettinger <[EMAIL PROTECTED]> wrote: > In Py2.6, I will mostly likely put in an automatic promotion to long > for both enumerate() and count(). It took a while to figure-out how > to do this without killing the performance for normal cases (ones used > in real programs,

Re: enumerate overflow

2007-10-03 Thread Hrvoje Niksic
Raymond Hettinger <[EMAIL PROTECTED]> writes: > [Paul Rubin] >> I hope in 3.0 there's a real fix, i.e. the count should promote to >> long. > > In Py2.6, I will mostly likely put in an automatic promotion to long > for both enumerate() and count(). It took a while to figure-out how > to do this w

Re: enumerate overflow

2007-10-03 Thread Paul Rubin
Raymond Hettinger <[EMAIL PROTECTED]> writes: > In Py2.6, I will mostly likely put in an automatic promotion to long > for both enumerate() and count(). It took a while to figure-out how > to do this without killing the performance for normal cases (ones used > in real programs, not examples contr

Re: enumerate overflow

2007-10-03 Thread Raymond Hettinger
[Paul Rubin] > I hope in 3.0 there's a real fix, i.e. the count should promote to > long. In Py2.6, I will mostly likely put in an automatic promotion to long for both enumerate() and count(). It took a while to figure-out how to do this without killing the performance for normal cases (ones used

Re: enumerate overflow

2007-10-03 Thread Paul Rubin
Tim Chase <[EMAIL PROTECTED]> writes: > I'd consider this a bug: either in the implementation of enumerate(), > or in the documentation > > http://docs.python.org/lib/built-in-funcs.html#l2h-24 2.5 has a patch that causes enumerate() and count() to raise overflow if the count wraps around, which

Re: enumerate overflow

2007-10-03 Thread Tim Golden
Steve Holden wrote: > I wouldn't dream of suggesting it's impossible. > I just regard "soon" as less than an hour in > commuter's terms, I suppose. Sadly, speaking as a Londoner, an hour is indeed "soon" in commuter terms. TJG -- http://mail.python.org/mailman/listinfo/python-list

Re: enumerate overflow

2007-10-03 Thread Steve Holden
Tim Chase wrote: >>> for lineNum, line in enumerate(f): ... >>> >>> However, lineNum soon overflows and starts counting backwards. How do >>> i force enumerate to return long integer? >>> >> Just how "soon" exactly do you read sys.maxint lines from a file? I >> should have thought that it would ta

Re: enumerate overflow

2007-10-03 Thread Tim Chase
>> for lineNum, line in enumerate(f): ... >> >> However, lineNum soon overflows and starts counting backwards. How do >> i force enumerate to return long integer? >> > Just how "soon" exactly do you read sys.maxint lines from a file? I > should have thought that it would take a significant amount

Re: enumerate overflow

2007-10-03 Thread Steve Holden
[EMAIL PROTECTED] wrote: > Hello all, > > in python2.4, i read lines from a file with > > for lineNum, line in enumerate(f): ... > > However, lineNum soon overflows and starts counting backwards. How do > i force enumerate to return long integer? > Just how "soon" exactly do you read sys.maxint

Re: enumerate overflow

2007-10-03 Thread Tim Chase
>> in python2.4, i read lines from a file with >> >> for lineNum, line in enumerate(f): ... >> >> However, lineNum soon overflows and starts counting backwards. How do >> i force enumerate to return long integer? > > Most probably you can't, because it is a C-written function I presume. > > But a

Re: enumerate overflow

2007-10-03 Thread Diez B. Roggisch
[EMAIL PROTECTED] schrieb: > Hello all, > > in python2.4, i read lines from a file with > > for lineNum, line in enumerate(f): ... > > However, lineNum soon overflows and starts counting backwards. How do > i force enumerate to return long integer? Most probably you can't, because it is a C-wri