![](https://secure.gravatar.com/avatar/047f2332cde3730f1ed661eebb0c5686.jpg?s=120&d=mm&r=g)
Eric has been looking into this. It's probably the only solution if we can't get immutable objects. But I would prefer the latter, if we can get the performance penalty low enough. On Thu, Dec 16, 2021 at 2:31 AM Victor Stinner <vstinner@python.org> wrote:
Hi,
One option to solve the https://bugs.python.org/issue40601 "[C API] Hide static types from the limited C API" issue without breaking the backward compatibility is to leave the C API and the stable ABI as they are for the main interpreter (static types), but force subinterpreters running in parallel to use their own heap types. It means that subinterpreters would be able to use the main interpreter GIL or own their GIL. By default, the GIL would still be shared.
C extensions using "&PyLongType" (static type) would continue to work in the main interpreter.
C extensions which want to opt-in for running subinterpreters in parallel would not access to "&PyLong_Type" but be forced to call PyLong_GetType() (heap type).
Internally, Python should be modified to replace "&PyLongType" with PyLong_GetType(). So the code would work with static types and heap types.
It also means that a subinterpreter running in parallel would only be able to import C extensions built with explicit support for this feature. Otherwise, an ImportError would be raised.
Victor -- Night gathers, and now my watch begins. It shall not end until my death. _______________________________________________ Python-Dev mailing list -- python-dev@python.org To unsubscribe send an email to python-dev-leave@python.org https://mail.python.org/mailman3/lists/python-dev.python.org/ Message archived at https://mail.python.org/archives/list/python-dev@python.org/message/QTY25AHC... Code of Conduct: http://python.org/psf/codeofconduct/
-- --Guido van Rossum (python.org/~guido) *Pronouns: he/him **(why is my pronoun here?)* <http://feministing.com/2015/02/03/how-using-they-as-a-singular-pronoun-can-change-the-world/>