https://github.com/python/cpython/commit/608192ee2f6c60aaae1c6f2f64ea45ad2667ff2d
commit: 608192ee2f6c60aaae1c6f2f64ea45ad2667ff2d
branch: main
author: Sam Gross <[email protected]>
committer: colesbury <[email protected]>
date: 2024-05-03T11:33:05-04:00
summary:

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.

files:
M Objects/moduleobject.c

diff --git a/Objects/moduleobject.c b/Objects/moduleobject.c
index d877edaf5453e1..a570b13e120863 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;

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: [email protected]

Reply via email to