On Wed, Aug 1, 2018 at 2:20 PM, Simon Cross firstname.lastname@example.org wrote:
On Wed, Aug 1, 2018 at 10:33 PM, Stefan Behnel email@example.com wrote:
It's faster under PyPy because their JIT can understand and optimise it. Or, more specifically, its usage in jitted code, so you get unboxed native calls instead of Python API calls. CPython does not have a JIT, that's why it's slower there. Doesn't really have anything to do with the C-API as such.
I think it was this kind of dynamic optimization that Victor was hoping might one day make it into CPython (and was blocked by the current complex C-API).
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.