[issue4194] Miserable subprocess.Popen performance
Skip Montanaro
report at bugs.python.org
Sat Oct 25 16:11:34 CEST 2008
Skip Montanaro <skip at pobox.com> added the comment:
>> Using a nonzero bufsize parameter makes all the difference in the
>> world:
...
In fact, looking at posix_popen in posixmodule.c it appears the default
value for bufsize there is -1, implying that I/O is fully buffered.
Even if the default bufsize value for subprocess.Popen is not changed its
documentation should be corrected to reflect the different default values
for bufsize between os.popen and subprocess.Popen:
Replacing os.popen*
-------------------
pipe = os.popen(cmd, mode='r', [bufsize])
==>
pipe = Popen(cmd, shell=True, bufsize=bufsize, stdout=PIPE).stdout
If you use the default bufsize with os.popen you must set bufsize to -1
when creating a Popen object. Otherwise your I/O will be unbuffered and
you will be disappointed at the I/O performance.
----------
assignee: -> georg.brandl
components: +Documentation, Library (Lib)
nosy: +georg.brandl
versions: +Python 2.7, Python 3.0
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue4194>
_______________________________________
More information about the Python-bugs-list
mailing list