Can subinterpreters import extension packages?

I want to know dose subinterpreter which has its GIL can import the extension package? Just like numpy, pyarrow et.al.

The extension modules have to specifically indicate that they support it. I imagine many don’t do this right now.

Does Cython do this automatically or is it something that the author of a Cython module would need to opt in to somehow?

I think we can import the extension modules in the main interpreter. Isn’t there method to share the modules which is imported in main interpreter to sub-interpreter? (If not change the package configration, we may sure the isolation for sub-interpreter) Or will Cpython support this chose?

Right now Cython doesn’t support it. It requires “isolated module state” - that each sub interpreter has its own copy of the module contents. Some progress has been made on that but not enough for this to work.

If/when it works, I suspect it’ll still be opt-in though. For a “pure-Cython” module then the isolated module state is all you need. However, for anything wrapping an external library it’ll need evaluating by the author.