On Thu, Dec 16, 2021 at 4:34 AM Antoine Pitrou <antoine@python.org> wrote:
As a data point, in PyArrow, we have a bunch of C++ code that interacts with Python but doesn't belong in a particular Python module. That C++ code can of course have global state, including perhaps Python objects.
Thanks for that example!
What might be nice would be a C API to allow creating interpreter-local opaque structs, for example:
void* Py_GetInterpreterLocal(const char* unique_name); void* Py_SetInterpreterLocal(const char* unique_name, void* ptr, void(*)() destructor);
That's interesting. I can imagine that as just a step beyond the module state API, with the module being implicit. Do you think this would be an improvement over using module state? (I'm genuinely curious.) -eric