STINNER Victor <[EMAIL PROTECTED]> 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 <[EMAIL PROTECTED]>
<http://bugs.python.org/issue4194>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to