[Python-3000] print() flushing problem.
Guido van Rossum
guido at python.org
Wed Nov 7 18:17:38 CET 2007
There's clearly a bug somewhere, maybe several. Can you file a bug
report at bugs.python.org, clearly stating the expected behavior and
the observed behavior, preferably with sample code? Studying the
source code and providing a patch would be much appreciated as well!
On 11/7/07, Wojciech Walczak <wojtek.gminick.walczak at gmail.com> wrote:
> 2007/11/7, Daniel Stutzbach <daniel at stutzbachenterprises.com>:
> > print() shouldn't flush if there isn't a newline, unless the buffer is
> > full or the user calls flush().
> So the buffer size in py3k is 1 byte long? Try this as a script in py3k:
> import time
> First print() will flush immediately even though there is no newline
> and flush is not called, while second print() will flush after second
> What I am saying is that print() is not flushing immediately when
> string is 1 byte long, but when it is longer - then print() is
> flushing immediately. It works that way both for interpreter and
> > The patch you suggest would cause a flush after *every* write with
> > print, which would cause a very significant performance hit on
> > programs that do a lot of writing to standard output (especially if
> > standard output is a pipe).
> No, it is calling flush only when the 'end' in print() is set.
> Otherwise (end==NULL or end==Py_None) it just prints newline as it was
> doing before. Anyway - I agree that it is a hit for performance and as
> I said before, I think that the problem lies somewhere deeper. Any
> Wojciech Walczak
> Python-3000 mailing list
> Python-3000 at python.org
> Unsubscribe: http://mail.python.org/mailman/options/python-3000/guido%40python.org
--Guido van Rossum (home page: http://www.python.org/~guido/)
More information about the Python-3000