[SciPy-User] Python seek argument type
Jorge E. ´Sanchez Sanchez
hnry2k at hotmail.com
Wed Apr 14 13:25:18 EDT 2010
As far as I understand the biggest long int in C you can manage in a 32bit machine is 2147483647, in order to work with bigger numbers than this you had to use the gmp library (general multiple precision) which also has a python module gmpy, you can have more information from http://gmpy.sourceforge.net/.
Best Regards
Jorge
Date: Wed, 14 Apr 2010 10:10:04 -0700
From: kuiper at jpl.nasa.gov
To: scipy-user at scipy.org
Subject: Re: [SciPy-User] Python seek argument type
Date: Wed, 14 Apr 2010 10:55:56 -0500
From: Robert Kern <robert.kern at gmail.com>
Subject: Re: [SciPy-User] Python seek argument type
To: SciPy Users List <scipy-user at scipy.org>
On Wed, Apr 14, 2010 at 10:53, Tom Kuiper <kuiper at jpl.nasa.gov> 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)
Tom
_________________________________________________________________
Enciende tu hotness con Hotmail
www.hotmailhotness.com.mx
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.scipy.org/pipermail/scipy-user/attachments/20100414/60ad3625/attachment.html>
More information about the SciPy-User
mailing list