0
votes

I am working on a Linux multi-core machine on which I simply call a same Python script with the interpreter on the command line (really just "python script.py") several times simultaneously. I see that performance is much slower than for a single call even though I am well within machine resources. I believe that is because the instances share the interpreter through Global Interpreter Lock (GIL) - i.e. several instances end up running "single core" no matter what. If I do the same thing with a frozen Python binary version of the script (http://wiki.python.org/moin/Freeze), would that happen as well? I believe not, because the binary "carries its own interpreter"?

1
The GIL is shared between threads in a single Python process. This doesn't apply if you're running several instances of a script. So something other than the GIL is causing your problem. - Michael Mior

1 Answers

3
votes

Your belief is wrong. The GIL is process-global. Separate CPython processes share nothing, not even the GIL. Only threads within the same process compete for the same global lock. The performance degradation you see much have another cause. And yes, the rules are the same for frozen executables IIUC.