The fastest way to call a process from python?
What is the fastest/most efficient way to execute an executable from python? In my opinion, os.system is faster than subprocess.popen. I would like to be able to read lines from other processes, but more than anything else is speed.
Solution
I expect os.system
and os.execv
and subprocess.
Any speed difference between Popens overwhelms the expense of starting a new process (and the context switch required to actually run it). Therefore, I recommend using subprocess
first and measuring performance.
One possible performance consideration: os.system
and subprocess. Popen(shell=True, ...)
Causes an additional shell process to be created. In most cases, this shell is not required. It’s wasteful to create it; You get twice as many processes as you need, but there are no benefits.