Skip to content

Commit c02223e

Browse files
committed
remove redundant lock
1 parent aaaec25 commit c02223e

2 files changed

Lines changed: 5 additions & 10 deletions

File tree

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Make ``type_setattro`` use defer refcount in free-threading for functions without defer refcount.
1+
Improve multithreaded scaling of dataclasses on the free-threaded build.

Objects/typeobject.c

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6547,14 +6547,10 @@ type_setattro(PyObject *self, PyObject *name, PyObject *value)
65476547
assert(!_PyType_HasFeature(metatype, Py_TPFLAGS_MANAGED_DICT));
65486548

65496549
#ifdef Py_GIL_DISABLED
6550-
if (value != NULL && PyFunction_Check(value)) {
6551-
if (!_PyObject_HasDeferredRefcount(value)) {
6552-
BEGIN_TYPE_LOCK();
6553-
if (!_PyObject_HasDeferredRefcount(value)) {
6554-
PyUnstable_Object_EnableDeferredRefcount(value);
6555-
}
6556-
END_TYPE_LOCK();
6557-
}
6550+
if (value != NULL &&
6551+
PyFunction_Check(value) &&
6552+
!_PyObject_HasDeferredRefcount(value)) {
6553+
PyUnstable_Object_EnableDeferredRefcount(value);
65586554
}
65596555
#endif
65606556

@@ -6585,7 +6581,6 @@ type_setattro(PyObject *self, PyObject *name, PyObject *value)
65856581
}
65866582
}
65876583

6588-
65896584
BEGIN_TYPE_DICT_LOCK(dict);
65906585
res = type_update_dict(type, (PyDictObject *)dict, name, value, &old_value);
65916586
assert(_PyType_CheckConsistency(type));

0 commit comments

Comments
 (0)