writing large files quickly

Tim Peters tim.peters at gmail.com
Sat Jan 28 12:27:05 EST 2006


[Jens Theisen]
> ...
> Actually I'm not sure what this optimisation should give you anyway. The
> only circumstance under which files with only zeroes are meaningful is
> testing, and that's exactly when you don't want that optimisation.

In most cases, a guarantee that reading "uninitialized" file data will
return zeroes is a security promise, not an optimization.  C doesn't
require this behavior, but POSIX does.

On FAT/FAT32, if you create a file, seek to a "large" offset, write a
byte, then read the uninitialized data from offset 0 up to the byte
just written, you get back whatever happened to be sitting on disk at
the locations now reserved for the file.  That can include passwords,
other peoples' email, etc -- anything whatsoever that may have been
written to disk at some time in the disk's history.  Security weenies
get upset at stuff like that ;-)



More information about the Python-list mailing list