[Python-3000] Draft PEP for New IO system (original) (raw)

Jim Jewett jimjjewett at gmail.com
Thu Mar 1 19:41:56 CET 2007


On 2/28/07, Daniel Stutzbach <daniel.stutzbach at gmail.com> wrote:

What should Buffered I/O .write() do for a non-blocking object?

It seems like the .write() should write as much as it can to the Raw I/O object and buffer the rest, but then how do we tell the Buffered I/O object to "write more data from the buffer but still don't block"?

Why bother?

The buffer layer should ensure that it gets written eventually, if only at buffer finalization.

A (blocking) flush says "commit whatever you have right now".

Needing anything in between is probably rare enough that it makes sense to let concrete objects handle it on their own, without a standardized method. This semi-flush seems far less important than a non-blocking read, which Guido has already said doesn't need standardization.

Option #2: Calling .write() with no arguments causes the Buffer I/O object to flush as much write data to the raw object, but won't block.

Writing a zero-length string should probably give it another chance to process the buffer if it wants to, but ... I don't think it should be forced to try, if it doesn't think there is enough data yet. That is what flush is for.

-jJ



More information about the Python-3000 mailing list