[Python-ideas] Pythonic buffering in Py3 print()

Stefan Behnel stefan_ml at behnel.de
Mon Jan 9 11:51:49 CET 2012


anatoly techtonik, 09.01.2012 11:30:
> In Python 2 "print 'something', statement calls were unbuffered and
> immediately appeared on screen.
> In Python 3 "print('something', end='')" calls are buffered. This breaks
> progress bars and other stuff.
> 
> 1. What is more "Pythonic" and why?

I find the Py3 behaviour more pythonic: flushing should be explicit (which
is better than implicit). The mere fact that the user did *not* provide a
terminator shows that there are likely other things to follow. A progress
bar is just one specific case where flushing is actually desired. In other
cases, it may not be desired and would rather lead to performance issues.
Making it implicit if a flush happens or not prevents users from
controlling it.


> 2. Should Python 3 be fixed ASAP?

IMHO, no.

Stefan




More information about the Python-ideas mailing list