The with gil branch brings some neat features. You can now say ‘with gil:’ and have any GIL-requiring code inside that block. Exceptions are propagated through nogil code and try/finally may now be used if there is a with gil block inside the try.
Of course, if with gil is used from a cdef function from a non-Python thread, it is the user’s responsibility to call PyEval_InitThreads() beforehand, in the same way it’s needed for ‘with gil’ functions.
Whenever the user (c)imports cython.parallel, PyEval_InitThreads() is called on the user’s behalf, as only the OpenMP master thread is allowed to call PyGILState_Ensure(), but we need any OpenMP thread to be able to acquire the GIL.