@@ -418,6 +418,40 @@ definition with the same method name.
418
418
slot. This is helpful because calls to PyCFunctions are optimized more
419
419
than wrapper object calls.
420
420
421
+ .. c :function :: PyObject * PyCMethod_New (PyMethodDef *ml, PyObject *self, PyObject *module, PyTypeObject *cls)
422
+
423
+ Turn *ml * into a Python :term: `callable ` object.
424
+ The caller must ensure that *ml * outlives the :term: `callable `.
425
+ Typically, *ml * is defined as a static variable.
426
+
427
+ The *self * parameter will be passed as the *self * argument
428
+ to the C function in ``ml->ml_meth `` when invoked.
429
+ *self * can be ``NULL ``.
430
+
431
+ The :term: `callable ` object's ``__module__ `` attribute
432
+ can be set from the given *module * argument.
433
+ *module * should be a Python string,
434
+ which will be used as name of the module the function is defined in.
435
+ If unavailable, it can be set to :const: `None ` or ``NULL ``.
436
+
437
+ .. seealso :: :attr:`function.__module__`
438
+
439
+ The *cls * parameter will be passed as the *defining_class *
440
+ argument to the C function.
441
+ Must be set if :c:macro: `METH_METHOD ` is set on ``ml->ml_flags ``.
442
+
443
+ .. versionadded :: 3.9
444
+
445
+
446
+ .. c :function :: PyObject * PyCFunction_NewEx (PyMethodDef *ml, PyObject *self, PyObject *module)
447
+
448
+ Equivalent to ``PyCMethod_New(ml, self, module, NULL) ``.
449
+
450
+
451
+ .. c :function :: PyObject * PyCFunction_New (PyMethodDef *ml, PyObject *self)
452
+
453
+ Equivalent to ``PyCMethod_New(ml, self, NULL, NULL) ``.
454
+
421
455
422
456
Accessing attributes of extension types
423
457
---------------------------------------
0 commit comments