writing large files quickly

Paul Rubin http
Fri Jan 27 14:30:16 EST 2006

Tim Chase <python.list at tim.thechases.com> writes:
> Is there anything preventing one from just doing the following?
> 	fd.write("0" * 409600000)
> It's one huge string for a very short time.  It skips all the looping
> and allows Python to pump the file out to the disk as fast as the OS
> can handle it. (and sorta as fast as Python can generate this
> humongous string)

That's large enough that it might exceed your PC's memory and cause
swapping.  Try strings of about 64k (65536).

More information about the Python-list mailing list