[Cython] Reason for __Pyx_PyObject_Call2Args, __Pyx_PyObject_Call3Args

Jeroen Demeyer J.Demeyer at UGent.be
Thu Jun 13 09:14:58 EDT 2019


Is there any particular reason why Cython has specific code like 
__Pyx_PyObject_Call2Args, __Pyx_PyObject_Call3Args, ...

And then there is even more complicated Python code in PyMethodCallNode 
generating something like __Pyx_PyObject_Call2Args for an arbitrary 
number of arguments.

This could be simplified a lot by just writing code once to deal with n 
arguments and then letting the C compiler do the clever stuff: if you 
write a loop where the number of iterations is a small compile-time 
constant, the compiler should unroll it.

I checked that GCC-6.4.0 is able to do this and the much simpler code 
with a for loop is as efficient as the current code. But maybe there are 
other compilers that don't do this (or there used to be such compilers 
when that code was written)?

I stumbled on this while working on 
https://github.com/cython/cython/issues/2996


More information about the cython-devel mailing list