Simon Cross schrieb am 02.08.2018 um 11:39:
On Thu, Aug 2, 2018 at 10:16 AM, Robert Bradshaw wrote:
There's nothing about the C-API that prevents a JIT (in fact numba can do exactly that, though its more focused on operating exclusively on unboxed types) and such a jit could optimize CFFI calls just as well. But so long as the default mode is interpreted, always operating on boxed objects, it will be slower.
Indeed, and as long as the C-API works with Python objects, a JIT has to pass actual boxed Python objects to code written using the C-API, which makes improving the performance of calls across the boundary between the "interpreter" and the C-API using code somewhat hopeless.
As long as we are just talking about calling such code, this is not true. A JIT compiler can be made to understand that the other side is natively implemented and use that information to call the underlying native function directly. PyPy's CFFI implementation does that. And there are discussions starting on providing a dedicated C call protocol for this as part of the C-API.