On Thu, Dec 16, 2021 at 2:29 AM Nathaniel Smith <n...@pobox.com> wrote: > On Wed, Dec 15, 2021 at 3:07 AM Victor Stinner <vstin...@python.org> wrote: > > I wrote https://bugs.python.org/issue39511 and > > https://github.com/python/cpython/pull/18301 to have per-interpreter > > None, True and False singletons. My change is backward compatible on > > the C API: you can still use "Py_None" in your C code. The code gets > > the singleton object from the current interpreter with a function > > call: > > > > #define Py_None Py_GetNone() > > > > Py_GetNone() is implemented as: "return _PyInterpreterState_GET()->none;" > > It's backward compatible for the C API, but not for the stable C ABI > -- that exports Py_None directly as a symbol.
You're right. But we can add a macro like Py_SUBINTERPRETER_API which would change the implementation: * By default, "Py_None" would continue returning "&_Py_NoneStruct". * If Py_SUBINTERPRETER_API macro is defined, Py_None would call Py_GetNone(). => no impact on the stable ABI (if used, the stable ABI is not supported) => no impact on performance (if not used) => only C extensions which opt-in for "subinterpreter running in parallel" support (define Py_SUBINTERPRETER_API) would be impacted. Stdlib C extensions would have to be built with Py_SUBINTERPRETER_API, but it is ok if the require a recent ABI since they are shipped with Python directly (and not currently built with the limited C API). 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-le...@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/WNPPGD5HXOMWNHHR7INW5JFBLEENWFIV/ Code of Conduct: http://python.org/psf/codeofconduct/