[issue4194] default subprocess.Popen buffer size

STINNER Victor report at bugs.python.org
Mon Nov 24 16:32:24 CET 2008


STINNER Victor <victor.stinner at haypocalc.com> added the comment:

> Victor> About Python3, os.popen() is more than two times faster (...)
> Victor> The difference is just this instruction:
> Victor>    stdout = io.TextIOWrapper(stdout)
>
> This is a known issue.  The default for bufsize in os.popen is -1 (fully
> buffered? line buffered?).  The default for bufsize in subprocess.Popen is
> 0 (unbuffered).

Wrong, it's not related to the buffer size.

With Python3 trunk on Linux, os.popen time is ~0.10 sec whereas 
subprocess.Popen is ~0.25 sec. Change the buffer size of subprocess doesn't 
help:
 - (default) 0.25
 - buffering = (-1):  0.25
 - buffering = 1:     0.25
 - buffering = 8192:  0.26
 - buffering = 16384: 0.26
(it's a little big slower with a bigger buffer...)

You get the same speed (than os.popen) using TextIOWrapper() adapter:
  [i for i in read_handle] => 0.25 sec
  [i for i in io.TextIOWrapper(read_handle)] => 0.10 sec

WTF? Unicode is *FASTER* than raw bytes?

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue4194>
_______________________________________


More information about the Python-bugs-list mailing list