Avoiding excessive writes

Gabriel Genellina gagsl-py2 at yahoo.com.ar
Wed Mar 18 22:20:34 EDT 2009


En Thu, 19 Mar 2009 00:52:54 -0200, <prometheus235 at gmail.com> escribió:

> I'm aware that C, and thus Python I suppose, will cache file writes
> for efficiency and to avoid excessive disk activity,

Python 2.X, yes, because it uses C file streams (FILE) to implement Python  
file objects. Python 3.x avoids that layer.

> Does the cache get written simply when an X-byte buffer fills up, and
> can I change X?

Yes, use the bufsize argument to open.

> Does it write after waiting so long?

I don't think so. You may call flush() yourself after some time.

-- 
Gabriel Genellina




More information about the Python-list mailing list