New API functions should take a "context" as a first argument -- similar to PyThreadState * that a lot of current internal API takes, except opaque.
In the future, this should allow:
hopefully, a regular function argument will be easier to handle for future exotic platforms (the next Wasm)
run-time flag to enable debug checks (with a HPy-style function table)
prviding a limited context for destructors (so they can't run arbitrary Python code)
Functions that don't take a context argument should those that are safe to use before Python is initialized. (These e.g. PyStatus rather than exception objects for error handling.)
Current API that doesn't do this will need to call PyThreadState_Get before calling the new API.
New API functions should take a "context" as a first argument -- similar to
PyThreadState *
that a lot of current internal API takes, except opaque.In the future, this should allow:
Functions that don't take a context argument should those that are safe to use before Python is initialized. (These e.g.
PyStatus
rather than exception objects for error handling.)Current API that doesn't do this will need to call
PyThreadState_Get
before calling the new API.