Nick Coghlan <ncoghlan <at> gmail.com> writes: > > The tempfile module would be another example.
Do you really need your temporary files to survive system crashes? ;) > For that reason, I think Steven's idea of a filetools module which > provided context managers and the like that wrapped *existing* file-like > objects might be preferable. Well, well, let's clarify things a bit. If we want to help users with this problem, we can provide two things: 1. a new sync() method on the standard objects provided by the IO lib 2. a facility to automatically call sync() on flush() and/or close() calls Step 1 may be done with a generic implementation in the IO ABCs calling self.flush() and then os.fsync(self.fileno()). IMO it is important that it is a method of IO objects because implementations may want to override it. An external facility would be too inflexible. Step 2 may be done with a generic wrapper. However, we could also provide an open() flag which transparently invokes the wrapper. After all, open() is already a convenience function creating a raw file object and wrapping it in two optional layers. (as a side note, wrappers have a non-zero performance impact, especially on small ops - e.g. reading or writing a few bytes) _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com