Closed
Description
Feature or enhancement
Proposal:
In #132070, there was a race brought up in free-threading through use of Py_REFCNT(op) == 1
. The fix is to use _PyObject_IsUniquelyReferenced
.
There were a couple additional comments about how we should handle this for the public API (for example, @godlygeek suggested implementing Py_REFCNT
as _PyObject_IsUniquelyReferenced(op) ? 1 : INT_MAX
). I think the best approach is to just expose an unstable API for this and point to it in Py_REFCNT
's documentation.
I'm not imagining anything complex:
int
PyUnstable_Object_IsUniquelyReferenced(PyObject *op)
{
return _PyObject_IsUniquelyReferenced(op);
}
@encukou, do you mind if this skips the C API WG? I'm not sure there's much to discuss about the API, other than some light bikeshedding.
Has this already been discussed elsewhere?
No response given
Links to previous discussion of this feature:
No response