@@ -399,6 +399,40 @@ definition with the same method name.
399399 slot. This is helpful because calls to PyCFunctions are optimized more
400400 than wrapper object calls.
401401
402+ .. c :function :: PyObject * PyCMethod_New (PyMethodDef *ml, PyObject *self, PyObject *module, PyTypeObject *cls)
403+
404+ Turn *ml * into a Python :term: `callable ` object.
405+ The caller must ensure that *ml * outlives the :term: `callable `.
406+ Typically, *ml * is defined as a static variable.
407+
408+ The *self * parameter will be passed as the *self * argument
409+ to the C function in ``ml->ml_meth `` when invoked.
410+ *self * can be ``NULL ``.
411+
412+ The :term: `callable ` object's ``__module__ `` attribute
413+ can be set from the given *module * argument.
414+ *module * should be a Python string,
415+ which will be used as name of the module the function is defined in.
416+ If unavailable, it can be set to :const: `None ` or ``NULL ``.
417+
418+ .. seealso :: :attr:`function.__module__`
419+
420+ The *cls * parameter will be passed as the *defining_class *
421+ argument to the C function.
422+ Must be set if :c:macro: `METH_METHOD ` is set on ``ml->ml_flags ``.
423+
424+ .. versionadded :: 3.9
425+
426+
427+ .. c :function :: PyObject * PyCFunction_NewEx (PyMethodDef *ml, PyObject *self, PyObject *module)
428+
429+ Equivalent to ``PyCMethod_New(ml, self, module, NULL) ``.
430+
431+
432+ .. c :function :: PyObject * PyCFunction_New (PyMethodDef *ml, PyObject *self)
433+
434+ Equivalent to ``PyCMethod_New(ml, self, NULL, NULL) ``.
435+
402436
403437Accessing attributes of extension types
404438---------------------------------------
0 commit comments