[Python-3000] print() flushing problem.

Guido van Rossum guido at python.org
Fri Nov 9 01:51:51 CET 2007

On Nov 8, 2007 12:34 PM, Luke Stebbing <luke.stebbing at gmail.com> wrote:
> On 11/8/07, Wojciech Walczak <wojtek.gminick.walczak at gmail.com> wrote:
> > Got it! Please, take a look at my patch. It's in the attachment. I am
> > still digging in the source, but I think that I have found the core of
> > the bug.
> > Without that patch "ret=sys.stdout.write('x')" acts in the same way as
> > print('x',end=''), which is - it prints nothing. After applying the
> > patch it is allright for both sys.stdout.write() and for print().
> If the buffer size is 1, isn't that arguably the correct behavior,
> i.e. don't flush until you have _more_ data than you can store?

Well, passing '1' as the buffer size to open() is supposed to set the
buffer size to the default value (typically 8K) *and* set a special
flag that forces a flush() whenever a line end is written. But this
isn't implemented; instead, it just flushes after each character...
(Which has the desired effect of not buffering interactive output, but
does it very inefficiently.)

--Guido van Rossum (home page: http://www.python.org/~guido/)

More information about the Python-3000 mailing list