On 11Jun2019 1842, Joe Jevnik via capi-sig wrote:
One idea I have is to change PyCFunctionObject to hold a PyMethodDef *value* instead of a pointer. I don't think the extra foot print size will affect much, and will lower the total memory usage of a PyCFunctionObject by one pointer. If anything, it avoids a second indirection to find the function's implementation. I wanted to poll this list before working on this to see if this has already been discussed or if I am just doing something wrong. PyCFunctionObject is not part of the limited ABI, so this should be a stable ABI compatible change. We can make this same change in PyType_Ready for statically allocated types.
As Jeroen suggested, I think it's not just okay but a *good* thing for PyCFunctionObject to not have to refer back to the PyMethodDef. I've certainly run into this problem before.
We can still use PyMethodDef as the input value, but unless we have a particular public API for retrieving it (which I don't recall we do), it may as well just go away at that point.
My guess is it made perfect sense when everything was static, but no longer does now.
Cheers, Steve