[Python-Dev] Making PyInterpreterState an opaque type
ericsnowcurrently at gmail.com
Fri Feb 15 18:37:53 EST 2019
I've been working on the runtime lately, particularly focused on my
multi-core Python project. One thing that would help simplify changes
in this area is if PyInterpreterState were defined in
Include/internal. This would mean the type would be opaque unless
Py_BUILD_CORE were defined.
The docs  already say none of the struct's fields are public.
Furthermore, Victor already moved it into Include/cpython (i.e. not in
the stable ABI) in November. Overall, the benefit of making internal
types like this opaque is realized in our ability to change the
internal details without further breaking C-API users.
Realistically, there may be extension modules out there that use
PyInterpreterState fields directly. They would break. I expect there
to be few such modules and fixing them would not involve great effort.
We'd have to add any missing accessor functions to the public C-API,
which I see as a good thing. I have an issue  open for the change
and a PR open. My PR already adds an entry to the porting section of
the 3.8 What's New doc about dealing with PyInterpreterState.
Anyway, I just wanted to see if there are any objections to making
PyInterpreterState an opaque type outside of core use.
p.s. I'd like to do the same with PyThreadState, but that's a bit
trickier  and not one of my immediate needs. :)
More information about the Python-Dev