Message76328
> 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? |
|
Date |
User |
Action |
Args |
2008-11-24 15:32:24 | vstinner | set | recipients:
+ vstinner, skip.montanaro, georg.brandl, gregory.p.smith, giampaolo.rodola, LambertDW, wplappert, sameerd, bgh |
2008-11-24 15:32:24 | vstinner | link | issue4194 messages |
2008-11-24 15:32:23 | vstinner | create | |
|