write a 20GB file

Martin v. Loewis martin at v.loewis.de
Fri May 14 11:07:01 EDT 2010


> The code works fine. I just don't know how f.write works. It says that
> file.write won't write the file until file.close or file.flush.

You are misinterpreting the documentation. It certainly won't keep the
entire file in memory. Instead, it has a fixed-size buffer (something
like 8kiB or 32kiB) in which it writes and which it flushes when that
buffer is full.

The comment about flush and close merely refers to the problem that some
data may still be in the buffer at any point in time, unless you just
called close or flush.

HTH,
Martin



More information about the Python-list mailing list