You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The current C API is not compatible with per-interpreter GIL. For example, it contains global static types such as PyList_Type.
We should definitely add functions to access these and deprecate the old way of doing things. However, that old way of doing things is widely used. Removing it from the C-API would be a major compatibility break – one that I think Python should not make.
Instead, I propose having two kinds of subinterpreters:
one that shares the GIL with the main interpreter and has no functional limitations,
and one with its own GIL, which can only load extension modules built without the problematic API, and can't start interpreters of the first kind.
This way, individual module authors can start opting in, starting with modules that would be most used (an useful) with separate GILs.
(But I'm in no rush to start working on this; lots of other issues – and converting the whole stdlib – can be tackled first.)
The text was updated successfully, but these errors were encountered:
Removing it from the C-API would be a major compatibility break – one that I think Python should not make.
How bad would it be if we changed all Py*_Type from PyTypeObject to PyTypeObject * (a la PyExc_*)? The fix is a single search-and-replace (&Py..._Type -> Py..._Type). Then (outside the limited API) we could turn all the global PyObject vars into macros that call the per-interpreter lookup function. (We can do this for the singletons and PyExc_* since they are already pointers.) The alternative is to update any C-API that might take Py*_Type to do the per-interpreter lookup (instead of the caller doing it).
Instead, I propose having two kinds of subinterpreters:
How bad would it be if we changed all Py*Type from PyTypeObject to PyTypeObject * (a la PyExc*)? The fix is a single search-and-replace (&Py..._Type -> Py..._Type).
Please, don't. That fix looks easy for actively maintained modules written in C, but the devil is in the details. The Python2 → 3 transition was supposed to be a bunch of easy fixes.
On the big picture: subinterpreters are a great feature, but not useful for everyone. Let's not make everyone pay for it, when there's a way to make it seamless with a bit more effort.
The current C API is not compatible with per-interpreter GIL. For example, it contains global static types such as
PyList_Type
.We should definitely add functions to access these and deprecate the old way of doing things. However, that old way of doing things is widely used. Removing it from the C-API would be a major compatibility break – one that I think Python should not make.
Instead, I propose having two kinds of subinterpreters:
This way, individual module authors can start opting in, starting with modules that would be most used (an useful) with separate GILs.
(But I'm in no rush to start working on this; lots of other issues – and converting the whole stdlib – can be tackled first.)
The text was updated successfully, but these errors were encountered: