This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author vstinner
Recipients LambertDW, bgh, georg.brandl, giampaolo.rodola, gregory.p.smith, sameerd, skip.montanaro, vstinner, wplappert
Date 2008-11-24.15:32:23
SpamBayes Score 2.2168859e-08
Marked as misclassified No
Message-id <200811241630.17769.victor.stinner@haypocalc.com>
In-reply-to <18730.50224.580059.974146@montanaro-dyndns-org.local>
Content
> 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?
History
Date User Action Args
2008-11-24 15:32:24vstinnersetrecipients: + vstinner, skip.montanaro, georg.brandl, gregory.p.smith, giampaolo.rodola, LambertDW, wplappert, sameerd, bgh
2008-11-24 15:32:24vstinnerlinkissue4194 messages
2008-11-24 15:32:23vstinnercreate