[SciPy-User] Python seek argument type
Wed Apr 14 12:10:04 CDT 2010
> Date: Wed, 14 Apr 2010 10:55:56 -0500
> From: Robert Kern <email@example.com>
> Subject: Re: [SciPy-User] Python seek argument type
> To: SciPy Users List <firstname.lastname@example.org>
> On Wed, Apr 14, 2010 at 10:53, Tom Kuiper <email@example.com> wrote:
>> Having disgraced myself with a not-to-bright question yesterday, let me
>> try again, still on the topic of reading binary files.
>> While trying to access the last record in the file I got:
>> ? ? 98 ? ? new_pos = pos+76*(index-current_index)
>> ? ? 99 ? ? print "Moving file index from",pos,"to",new_pos
>> --> 100 ? ? fd.seek(new_pos,0)
>> ? ?101 ? buf = fd.read(76)
>> ? ?102 ? data = unpack_from("=LLL dddd dddd", buf)
>> OverflowError: long int too large to convert to int
>> The argument in question, new_pos, has a value of 2,252,639,972, which
>> is slightly too large to be a Python signed int:
>> math.log(2252639972,2) = 31.068969607366373
>> and, of course, a Python int is a C long on a 32-bit machine, which is
>> the type specified for the first argument of the underlying C fseek command.
>> Now a 2.1 GB file is not large by modern standards. ?I imagine someone
>> must have come up with a way to position past the 2 billionth byte in a
>> file. ?Does anyone know what it is?
> What version of Python are you using? Python 2.4 definitely had
> problems like this, but I believe that 2.5 resolved them.
Python 2.5.2 (r252:60911, Jan 24 2010, 14:53:14)
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the SciPy-User