summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSam Gross <colesbury@gmail.com>2024-05-03 15:33:05 (GMT)
committerGitHub <noreply@github.com>2024-05-03 15:33:05 (GMT)
commit608192ee2f6c60aaae1c6f2f64ea45ad2667ff2d (patch)
tree0f25ea7e3737f3f8ba35905b8f15826d6ad0828c
parentc2627d6eea924daf80f374c18a5fd73ef61283fa (diff)
downloadcpython-608192ee2f6c60aaae1c6f2f64ea45ad2667ff2d.zip
cpython-608192ee2f6c60aaae1c6f2f64ea45ad2667ff2d.tar.gz
cpython-608192ee2f6c60aaae1c6f2f64ea45ad2667ff2d.tar.bz2
gh-118527: Use deferred reference counting for C functions on modules (#118529)
This addresses a scaling bottleneck in the free-threaded build when calling functions like `math.floor()` concurrently from multiple threads.
-rw-r--r--Objects/moduleobject.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/Objects/moduleobject.c b/Objects/moduleobject.c
index d877eda..a570b13 100644
--- a/Objects/moduleobject.c
+++ b/Objects/moduleobject.c
@@ -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;