What's the public API alternative to _PyObject_GC_IS_TRACKED()?

Inada Naoki songofacandy at gmail.com
Wed Dec 29 01:46:17 EST 2021


On Wed, Dec 29, 2021 at 5:18 AM Marco Sulla
<Marco.Sulla.Python at gmail.com> wrote:
>
>
> > 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.
>

You are right. I thought PyObject_GC_Track() can be used to tracked
objects because PyObject_GC_Untrack() can be used untracked object.
I think there is no enough reason for this asymmetry.

Additionally, adding PyObject_GC_IsTracked() to public API will not
bother future Python improvements.
If Python changed its GC to mark-and-sweep, PyObject_GC_IsTracked()
can return true always.

Regards,

-- 
Inada Naoki  <songofacandy at gmail.com>


More information about the Python-list mailing list