tags:

views:

37

answers:

3

hi, i am quite new to python.subprocess()

if i folk a new process from python, will the execution speed of this new process be compromised?

imagine that i have the

#python 
import subprocess
subprocess.call( MyBinary )

basically, is there any difference between

./MyBinary

and

./python ruMyBinary.py

?

+3  A: 

No. A separate process is a separate process. It competes for OS resources with all other processes "fairly".

Your python process that simply does subprocess.call is a process, and does consume some system resources. But relatively few, since it will be waiting for a system call to finish. It will occupy a slot in the process table, so it does have a microscopic impact.

S.Lott
A: 

No, the process runs just as if started by any other means.

unwind
hi, thanks a lot1 this is the first question that i posted on this website!
ccfenix
+2  A: 

Apart from having to actually run the python interpreter, no. So your last example will take some slight time before MyBinary to parse and run the python program and some slight time after it completes to terminate the python program. And the python program will be an existing process which takes up a pid and some amount of memory.

So the running speed of one long-running program won't be affekted. Hovever, if you run your executable thousands of times, any extra wrapping, wether in python or in something else, will cost.

Rasmus Kaj