[SciPy-User] Python seek argument type
Tom Kuiper
kuiper at jpl.nasa.gov
Wed Apr 14 11:53:31 EDT 2010
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?
Thanks and regards
Tom
More information about the SciPy-User
mailing list