On Tue, 28 Dec 2021 at 12:38, Inada Naoki <songofaca...@gmail.com> wrote: > Your case is special. > You want to create a frozendict which performance is same to builtin dict. > Builtin dict has special optimization which tightly coupled with > current CPython implementation. > So you need to use private APIs for MAINTAIN_TRACKING.
I solved this problem with a hacky trick: I included a reduced and slightly modified version of dictobject.c. Furthermore I copy / pasted stringlib\eq.h and _Py_bit_length. I'm currently doing this in a refactor branch. (Yes, I know that including a .c is very bad... but I need to do this to separate the code of dict from the code of frozendict. Putting all in the same files mess my head) > But PyObject_GC_Track() is a public API. The problem is I can't invoke PyObject_GC_Track() on an already tracked object. I tried it and Python segfaulted. That's why CPython uses _PyObject_GC_IS_TRACKED() before. I'll try to copy/paste it too... :D but I do not understand why there's not a public version of it. -- https://mail.python.org/mailman/listinfo/python-list