Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the performance overhead of Popen in python

compared to invoking a python library function that does the same thing. I've some legacy code that uses Popen to invoke a executable with some parameters.

Now there a python library that supports that same function. I was wondering what the performance implications are.

like image 847
Soumya Simanta Avatar asked Feb 01 '26 16:02

Soumya Simanta


1 Answers

Forking a separate process to do something is almost always much more expensive than calling a function that does the same thing. But if that Python function is very inefficient, and the OS forks new processes quickly (i.e., is a UNIX variant,) you could imagine a rare case where this is not true -- but it will definitely be rare.

like image 71
Ernest Friedman-Hill Avatar answered Feb 03 '26 04:02

Ernest Friedman-Hill



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!