[issue39511] [subinterpreters] Per-interpreter singletons (None, True, False, etc.)

STINNER Victor report at bugs.python.org
Tue Feb 4 18:59:24 EST 2020


STINNER Victor <vstinner at python.org> added the comment:

> The other approach is to leave the current static singletons alone and
> only use them for the main interpreter.  Each subinterpreter would get
> its own copy, created when that interpreter is initialized.

Which API should be used in C extensions to be "subinterpreter-safe"? Currently, Py_None is a singleton shared by multiple interpreters. Should suddenly all C extensions use a new Py_GetNone() function which returns the per-interpreter singleton? If yes, that's basically what my PR 18301 does:

   #define Py_None Py_GetNone()

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue39511>
_______________________________________


More information about the Python-bugs-list mailing list