Le mer. 19 juin 2019 à 10:39, Jeroen Demeyer <J.Demeyer@ugent.be> a écrit :
I did a quick count of calls being done using PyObject_CallFunction(), PyObject_CallFunctionObjArgs() and _PyObject_FastCall():
- There are 94 calls with 1 positional argument.
- There are 20 calls with 2 positional arguments.
- There are 11 calls with 3 positional arguments.
- There are 4 calls with 4 or more positional arguments.
Personally, I think that this is sufficient to justify the addition of the extra convenience functions for 1, 2 and maybe even 3 positional arguments.
Every single new function added to the C API is causing a large maintenance cost on the whole Python community. First, CPython will have to maintain it. Then other Python implementation like PyPy will have to implement it and maintain it as well. The current trend is to *reduce* the size of the C API rather than making it larger. http://pythoncapi.readthedocs.io/
*But* performance matters too. *Maybe* we can experiment _PyObject_CallOneArg(func, arg): check if it's faster or not and try to measure the stack consumption.
I don't think that we should add functions for 2 arguments or more. It's too rare and would cause too much maintenance burden compared to the benefit.
Victor
Night gathers, and now my watch begins. It shall not end until my death.