I just thought of something. I believe when we saw Sam Gross’s nogil presentations (a year ago, and again at the Language Summit) we were pretty skeptical of how much will break in 3rd party extension modules like numpy, because they might have some bit of mutable global state (perhaps hidden deep inside some esoteric corner of the code) that is protected by the GIL. Wouldn’t such cases also be broken when multiple interpreters have their own GIL?
The hypothetical case would be something like
bool
is_py_file(PyObject *obj)
{
assert(obj != NULL);
static PyObject *cache = NULL;
static bool cache_is_py_file = 0;
if (obj != cache) {
Py_CLEAR(cache);
Py_INCREF(obj);
cache = obj;
cache_is_py_file = <expensive computation>;
}
return cache_is_py_file;
}
Such code could be hidden in many places, and is currently protected by the GIL, even when using multiple interpreters.