To run Python code as a Go compiled executable. This allows them to avoid the Python Global Interpreter Lock (which severely limits Python's scalability within a single process) and run the Python code using Go modules as if they were Python modules.
Really, unless you're Google or another Python shop interesting in moving to Go, you probably don't have a use for this.
The global interpreter lock exists on a per-process basis in Python. Any two python scripts (including two instances of the same script) can be run in two different processes and do whatever. However, if one script starts multiple threads, only one thread will execute concurrently (the thread which has the interpreter lock).
This is a CPython implementation detail, and other Python runtimes need not have this limitation. The reason for GIL is because CPython's memory management is not thread-safe.
To add to this, there is a project to remove the GIL from CPython. However, it's not currently as fast as with the GIL. More info: https://lwn.net/Articles/689548/
Meaning threading will work just fine for network operations for the most part. It will perform worse than single threaded if doing something like simple math operations (like in the chart of the Fibonacci performance in the article).
As someone who doesn't use Go or Python: what is the use for this?
vplatt 301 points · Jan 2017
To run Python code as a Go compiled executable. This allows them to avoid the Python Global Interpreter Lock (which severely limits Python's scalability within a single process) and run the Python code using Go modules as if they were Python modules.
Really, unless you're Google or another Python shop interesting in moving to Go, you probably don't have a use for this.
MightyCreak 2 points · Jan 2017
Does this mean that you can't interpret two Python scripts at the same time because of GIL, but once interpreted, they can run in parallel?
ShotgunToothpaste 23 points · Jan 2017
The global interpreter lock exists on a per-process basis in Python. Any two python scripts (including two instances of the same script) can be run in two different processes and do whatever. However, if one script starts multiple threads, only one thread will execute concurrently (the thread which has the interpreter lock).
This is a CPython implementation detail, and other Python runtimes need not have this limitation. The reason for GIL is because CPython's memory management is not thread-safe.
https://wiki.python.org/moin/GlobalInterpreterLock
btgeekboy 10 points · Jan 2017
To add to this, there is a project to remove the GIL from CPython. However, it's not currently as fast as with the GIL. More info: https://lwn.net/Articles/689548/
[deleted] 3 points · Jan 2017
[deleted]
fireflash38 1 points · Jan 2017
Meaning threading will work just fine for network operations for the most part. It will perform worse than single threaded if doing something like simple math operations (like in the chart of the Fibonacci performance in the article).
ShotgunToothpaste 2 points · Jan 2017
Ahh, I wasn't aware that Python allowed for system calls to be multi-threaded outside of the GIL's constraints but that makes sense.
I assume that means GIL is released before making a system call, and re-acquired before continuing after it completes?
MightyCreak 2 points · Jan 2017
Thanks for this answer!