[New-bugs-announce] [issue4194] Miserable subprocess.Popen performance

Skip Montanaro report at bugs.python.org
Fri Oct 24 19:54:42 CEST 2008

New submission from Skip Montanaro <skip at pobox.com>:

I noticed a colleague at work today checked in a change to his code to
switch back from subprocess.Popen to os.popen.  I asked him about it and he
reported that subprocess.Popen was about 10x slower than os.popen.  I asked
him for a simple test case, which is attached.  Here are my results with
Python 2.4 through 2.7 (aka CVS HEAD):

    tmp% python2.4 popentest.py 
    time with os.popen :  0.09
    time with subprocess.Popen :  2.27
    tmp% python2.5 popentest.py 
    time with os.popen :  0.03
    time with subprocess.Popen :  1.52
    tmp% python2.6 popentest.py 
    time with os.popen :  0.038824
    time with subprocess.Popen :  1.517056
    tmp% python2.7 popentest.py 
    time with os.popen :  0.033746
    time with subprocess.Popen :  1.512331

These times are on my Mac laptop, all writing to the local disk.  It seems
there was a bit of improvement in the 2.5 release but that it is still
miserably slow when compared with os.popen.

His original test used time.clock() as the timer.  I changed to time.time()
but got essentially the same result.


files: popentest.py
messages: 75173
nosy: skip.montanaro
severity: normal
status: open
title: Miserable subprocess.Popen performance
Added file: http://bugs.python.org/file11871/popentest.py

Python tracker <report at bugs.python.org>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: popentest.py
URL: <http://mail.python.org/pipermail/new-bugs-announce/attachments/20081024/1d6202ba/attachment.txt>

More information about the New-bugs-announce mailing list