Python's GIL implemented in pure Python
Reading the headline I couldn’t help but think “But why?”. Actually quite interesting and valuable implementation info if you’re ever doing threading with CPython.
This is nice .. but it could be nicer with (pun intended) use of the context manager protocols, a few less empty lines and a bit of minor refactoring for readability.
Is execution_loop really meant to start and end holding the GIL?
> Note that this code will not run if you will try to execute it, because it's missing bytecode execution logic.
So much for "implemented".
Incidentally, apparently PyPy has a GIL too[1], complete with a detailed description in a source-code comment, similar to the one quoted in the linked article[2]. It's written in C. Isn't the point of PyPy that it's written in a Python subset?
[1]http://doc.pypy.org/en/latest/faq.html#does-pypy-have-a-gil-... [2]https://bitbucket.org/pypy/pypy/src/00f8eae1/rpython/transla...