mirror of https://github.com/python/cpython
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.
This commit is contained in:
parent
c2627d6eea
commit
608192ee2f
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue