Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
remove redundant lock
  • Loading branch information
LindaSummer committed Nov 17, 2025
commit c02223e6a24f5b64f839af3e21b1df73bd711c6d
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Make ``type_setattro`` use defer refcount in free-threading for functions without defer refcount.
Improve multithreaded scaling of dataclasses on the free-threaded build.
13 changes: 4 additions & 9 deletions Objects/typeobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -6547,14 +6547,10 @@ type_setattro(PyObject *self, PyObject *name, PyObject *value)
assert(!_PyType_HasFeature(metatype, Py_TPFLAGS_MANAGED_DICT));

#ifdef Py_GIL_DISABLED
if (value != NULL && PyFunction_Check(value)) {
if (!_PyObject_HasDeferredRefcount(value)) {
BEGIN_TYPE_LOCK();
if (!_PyObject_HasDeferredRefcount(value)) {
PyUnstable_Object_EnableDeferredRefcount(value);
}
END_TYPE_LOCK();
}
if (value != NULL &&
PyFunction_Check(value) &&
!_PyObject_HasDeferredRefcount(value)) {
PyUnstable_Object_EnableDeferredRefcount(value);
}
#endif

Expand Down Expand Up @@ -6585,7 +6581,6 @@ type_setattro(PyObject *self, PyObject *name, PyObject *value)
}
}


BEGIN_TYPE_DICT_LOCK(dict);
res = type_update_dict(type, (PyDictObject *)dict, name, value, &old_value);
assert(_PyType_CheckConsistency(type));
Expand Down
Loading