Skip to content
Merged
Changes from all commits
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
gh-118527: Use deferred reference counting for C functions on modules
This addresses a scaling bottleneck in the free-threaded build when
calling functions like `math.floor()` concurrently from multiple
threads.
  • Loading branch information
colesbury committed May 3, 2024
commit 11d421fad9b0c6d5e0b503eab19be8a7b70d4193
1 change: 1 addition & 0 deletions Objects/moduleobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ _add_methods_to_object(PyObject *module, PyObject *name, PyMethodDef *functions)
if (func == NULL) {
return -1;
}
_PyObject_SetDeferredRefcount(func);
if (PyObject_SetAttrString(module, fdef->ml_name, func) != 0) {
Py_DECREF(func);
return -1;
Expand Down