Skip to content

Commit a0bcabc

Browse files
committed
Move _PyObject_SetDeferredRefcount call up
1 parent a8c2e44 commit a0bcabc

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

Modules/_threadmodule.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1414,6 +1414,10 @@ local_new(PyTypeObject *type, PyObject *args, PyObject *kw)
14141414
return NULL;
14151415
}
14161416

1417+
// gh-128691: Use deferred reference counting for thread-locals to avoid
1418+
// contention on the shared object.
1419+
_PyObject_SetDeferredRefcount((PyObject *)self);
1420+
14171421
self->args = Py_XNewRef(args);
14181422
self->kw = Py_XNewRef(kw);
14191423

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

1438-
_PyObject_SetDeferredRefcount((PyObject *)self);
14391442
return (PyObject *)self;
14401443

14411444
err:

0 commit comments

Comments
 (0)