开发者

Will python.subprocess(cppBinaryExe) compromise cppBinaryExe's performance?

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 ruMyB开发者_Go百科inary.py

?


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.


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.


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜