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.

classification
Title: subprocess.Popen() is slower than subprocess.run()
Type: performance Stage: resolved
Components: Library (Lib) Versions: Python 3.5
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: Николай Соколов
Priority: normal Keywords:

Created on 2017-12-20 09:57 by Николай Соколов, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Messages (2)
msg308711 - (view) Author: Николай Соколов (Николай Соколов) Date: 2017-12-20 09:57
Hello.

I noticed different speed of application, which was execute with subprocess.Popen() and subprocess.run().

I tested on Linux Ubuntu 17.04 and Windows 10.
My command line is:
     "ffmpeg -i big_buck_bunny_480p_surround-fix.avi -f null -" 
you can use any video file on your PC.
I used ffmpeg (open source encoder/decoder/and etc.), but you can use any applications, which counts himself speed of work.

I got a difference in speed:

Using by terminal: fps=4402 (frame per second);
Using by run(): fps=4019;
Using by Popen(): fps=3431;

On Windows is difference about 5% percent, on Linux about 10% percent.

I did not use additional flags. All by default.
I downloaded video stream here https://peach.blender.org/download/
msg308724 - (view) Author: Николай Соколов (Николай Соколов) Date: 2017-12-20 11:33
I incorrectly used the loop to check if the process is alive:
while process.poll() is None:
    pass
else:
    stdout, stderr = process.communicate()
History
Date User Action Args
2022-04-11 14:58:55adminsetgithub: 76564
2017-12-20 11:33:51Николай Соколовsetstatus: open -> closed
resolution: not a bug
messages: + msg308724

stage: resolved
2017-12-20 09:57:21Николай Соколовcreate