writing large files quickly
Grant Edwards
grante at visi.com
Fri Jan 27 14:30:54 EST 2006
On 2006-01-27, rbt <rbt at athop1.ath.vt.edu> wrote:
> I've been doing some file system benchmarking. In the process, I need to
> create a large file to copy around to various drives. I'm creating the
> file like this:
>
> fd = file('large_file.bin', 'wb')
> for x in xrange(409600000):
> fd.write('0')
> fd.close()
>
> This takes a few minutes to do. How can I speed up the process?
Don't write so much data.
f = file('large_file.bin','wb')
f.seek(409600000-1)
f.write('\x00')
f.close()
That should be almost instantaneous in that the time required
for those 4 lines of code is neglgible compared to interpreter
startup and shutdown.
--
Grant Edwards grante Yow! These PRESERVES
at should be FORCE-FED to
visi.com PENTAGON OFFICIALS!!
More information about the Python-list
mailing list