Best way to write a file n-bytes long

Michael Peuser mpeuser at web.de
Sat Aug 30 04:25:37 EDT 2003


"Dialtone" <dialtone#NOSPAM#.despammed at aruba.it> schrieb im Newsbeitrag
news:87d6esxda2.fsf at vercingetorix.caesar.org...
> cappy2112 at yahoo.com (Tony C) writes:
>
[...]

> > st="X" * 1048576
> > fh=open("junk","wb")
> > fh.write(st)
> > fh.close()
>
> For little files (less than 2 or 3 Mb I think) your code is the
> fastest I can think of. But growing There is a new version which is a
> lot faster

All this is valid in a very limited scope only.
- Consider limited RAM (lets say 128 MB) - you will be extremely slowed down
by thrashing.
- Consider on-the-fly compression (Windows NTFS): The 1000 MB testdate will
be reduced to 1 Byte!

Kindly
Michael P







More information about the Python-list mailing list