Simon Cross schrieb am 01.08.2018 um 21:37:
I think these benchmarks support the general idea that changing the C API does open some doors to better performance (which is why PyPy folks wrote CFFI)?
Initially, they half-heartedly recommended ctypes as a way to write native code wrappers for both CPython and PyPy, and then they wrote CFFI because a) it matches their JIT better than ctypes and was easier to implement and optimise for them than the complex ctypes library, and b) they saw the FFI of luajit , which is much smarter and easier to use than ctypes, so they took it as a model.
The fact that there is a CFFI for CPython is mostly due to their wish to make people write native code wrappers that work on both systems, while being fast on PyPy. And because they are nice people who like writing cool software. :) But mostly, really, to keep people from writing low-level C-API code that they would then have to support in their cpyext emulation. So, actually very similar to Victor's intentions. The more high level the code is that people write, the easier it becomes to change the basement under their feet.