Message388409
> 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()
after read you [WIP] bpo-39511: Add Py_GetNone() and Py_GetNoneRef() functions #18301.
Actually, interp->none shared _Py_NoneStruct variable.
when two interperter modify interp->none refcount,will modify _Py_NoneStruct variable.
> the CPU cacheline of common singletons like None, True and False can quickly become a performance bottleneck.
even if add Py_INCREF(none);.
In the scenario of parallel interpreter, will also have thread safety issues.
> PyStatus
> _Py_InitSingletons(PyThreadState *tstate)
> {
> PyObject *none = &_Py_NoneStruct;
> Py_INCREF(none);
> tstate->interp->none = none;
> return _PyStatus_OK();
> } |
|
Date |
User |
Action |
Args |
2021-03-10 07:17:38 | JunyiXie | set | recipients:
+ JunyiXie, vstinner |
2021-03-10 07:17:38 | JunyiXie | set | messageid: <1615360658.63.0.230225616191.issue39511@roundup.psfhosted.org> |
2021-03-10 07:17:38 | JunyiXie | link | issue39511 messages |
2021-03-10 07:17:38 | JunyiXie | create | |
|