How to implement freelists in dict 3.10 for previous versions?

Inada Naoki songofacandy at gmail.com
Thu Dec 30 01:59:29 EST 2021


On Wed, Dec 29, 2021 at 7:25 PM Marco Sulla
<Marco.Sulla.Python at gmail.com> wrote:
>
> I noticed that now freelists in dict use _Py_dict_state. I suppose
> this is done for thread safety.
>

Some core-dev are working on per-interpreter GIL. But it is not done yet.
So you don't need to follow it soon. Your extension module will work
well in Python 3.11.

> I would implement it also for a C extension that uses CPython < 3.10.
> How can I achieve this?

See PyModule_GetState() to have per-interpreter module state instead
of static variables.
https://docs.python.org/3/c-api/module.html#c.PyModule_GetState


-- 
Inada Naoki  <songofacandy at gmail.com>


More information about the Python-list mailing list