Skip to content

Commit

Permalink
Move _PyObject_SetDeferredRefcount call up
Browse files Browse the repository at this point in the history
  • Loading branch information
colesbury committed Jan 10, 2025
1 parent a8c2e44 commit a0bcabc
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion Modules/_threadmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -1414,6 +1414,10 @@ local_new(PyTypeObject *type, PyObject *args, PyObject *kw)
return NULL;
}

// gh-128691: Use deferred reference counting for thread-locals to avoid
// contention on the shared object.
_PyObject_SetDeferredRefcount((PyObject *)self);

self->args = Py_XNewRef(args);
self->kw = Py_XNewRef(kw);

Expand All @@ -1435,7 +1439,6 @@ local_new(PyTypeObject *type, PyObject *args, PyObject *kw)
Py_DECREF(localsdict);
Py_DECREF(sentinel_wr);

_PyObject_SetDeferredRefcount((PyObject *)self);
return (PyObject *)self;

err:
Expand Down

0 comments on commit a0bcabc

Please sign in to comment.