>4GB files with python
ethan mindlace fremen
mindlace at imeme.net
Fri Mar 3 07:02:24 EST 2000
well, to continue my tradition of talking to myself:
i've compiled python as follows:
CFLAGS="-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64" OPT="-O2 $CFLAGS" \
./configure --with-threads
which gets the danged thing writing files past 2GB.
However, it then chokes and dies at precisely 4GB. Here's the (don't
laugh) code I used to test it:
#ethan's slap-dash big file maker.
import os
bigfile = open('bigfile', 'a')
# gigabyte x 23
filesize = ((2**30) * 23L)
blocksize = ((2**20) * 23L)
while blocksize > os.path.getsize('bigfile'):
bigfile.write('All work and no play makes jack a dull boy\n')
print os.path.getsize('bigfile')
bigfile.close
fatfile = open('fatfile', 'a')
bigfile = open('bigfile', 'r')
block = bigfile.read(blocksize)
while filesize > os.path.getsize('fatfile'):
fatfile.write(block)
kbytes = (os.path.getsize('fatfile') / (2**30L))
print kbytes
#end
--
emf - mindlace at imeme.net
good design is as close as I want to get to ideology.
More information about the Python-list
mailing list