Fastest way to call a process from python?

What is the fastest / most efficient way to execute an executable from python? It seems to me that os.system is faster than subprocess.popen. I would like to be able to read lines coming out of this other process, but much more important than anything else is speed.

+3
source share
1 answer

I would expect that any speed difference between, say, os.systemand os.execvand subprocess.Popen, will depend on the cost of starting a new process (and the context switch needed to actually start it). Therefore, I recommend using subprocessand measuring performance first.

: os.system subprocess.Popen(shell=True, ...) . . ; , .

+4

Source: https://habr.com/ru/post/1781496/


All Articles