Related Entries

India PyCon 2009
Quick wallpaper changer
Load testing with Grinder
Adding namespace to XML
Opera RSS to OPML

« New Datatypes, New Possibilities
» Free PDF creation

Testing large file support

Can your Python support files larger than 2GB?

Python documentation: “Several operating systems (including AIX, HPUX, Irix and Solaris) provide support for files that are larger than 2 Gb from a C programming model where int and long are 32-bit values. This is typically accomplished by defining the relevant size and offset types as 64-bit values. Such files are sometimes referred to as large files.”

Ok, how do you find out if your compiled python has large file support?

>>> fp = open("dummy.txt","w")
>>> fp.tell()
0L
>>> fp.close()

Note: delete dummy.txt afterwards.

The simple block above should tell you that. If tell() returns 0L that means, you’ve large file support enabled. You can safely process files larger than 2GB. How large these files can be? I guess that depends on the operating system.

If large file support is not available, tell() will return 0.

  1. Still, how would you find out programatically? This is visual verification.

    Posted by: wari on December 10, 2002 08:47 AM
  2. This might work - types.LongType == type(fp.tell()).

    Posted by: Babu on December 10, 2002 09:11 AM
//-->