When implementing, in some extension, a custom callable type similar to PyFunction_Type, one may want to set Py_TPFLAGS_METHOD_DESCRIPTOR in the tp_flags. In many such cases, the implementation of tp_descr_get is trivial and essentially that of PyFunction_Type:
if (obj == Py_None || obj == NULL) {
return Py_NewRef(func);
}
return PyMethod_New(func, obj);
PyMethod_New is currently not part of the stable ABI (I believe), and hence not part of the limited API. Since the functionality provided by PyMethod_Type is quite extensive, providing a local re-implementation of a similar type seems a bit wasteful (iff possible under limited API at all).
Assuming the prototype of PyMethod_New seems unlikely to change and only depends on PyObject * values, would the workgroup consider adding PyMethod_New to the stable ABI / limited API?
For reference, I believe nanobind has a local implementation of a similar type, though a cursory check seems to indicate it's less "advanced" than PyMethod_Type (e.g., it doesn't come with a __reduce__ method).
When implementing, in some extension, a custom callable type similar to
PyFunction_Type, one may want to setPy_TPFLAGS_METHOD_DESCRIPTORin thetp_flags. In many such cases, the implementation oftp_descr_getis trivial and essentially that ofPyFunction_Type:PyMethod_Newis currently not part of the stable ABI (I believe), and hence not part of the limited API. Since the functionality provided byPyMethod_Typeis quite extensive, providing a local re-implementation of a similar type seems a bit wasteful (iff possible under limited API at all).Assuming the prototype of
PyMethod_Newseems unlikely to change and only depends onPyObject *values, would the workgroup consider addingPyMethod_Newto the stable ABI / limited API?For reference, I believe
nanobindhas a local implementation of a similar type, though a cursory check seems to indicate it's less "advanced" thanPyMethod_Type(e.g., it doesn't come with a__reduce__method).