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 skip.montanaro
Recipients skip.montanaro
Date 2008-10-24.17:54:39
SpamBayes Score 5.430825e-07
Marked as misclassified No
Message-id <18690.3034.472764.227788@montanaro-dyndns-org.local>
In-reply-to
Content
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.

Skip
Files
File name Uploaded
popentest.py skip.montanaro, 2008-10-24.17:54:39
History
Date User Action Args
2008-10-24 17:54:42skip.montanarosetrecipients: + skip.montanaro
2008-10-24 17:54:41skip.montanarolinkissue4194 messages
2008-10-24 17:54:40skip.montanarocreate