[Python-Dev] Let's change to C API!

Armin Rigo armin.rigo at gmail.com
Fri Aug 10 13:15:11 EDT 2018


On 31 July 2018 at 13:55, Antoine Pitrou <solipsis at pitrou.net> wrote:
> It's just that I disagree that removing the C API will make CPython 2x
> faster.
> Actually, important modern optimizations for dynamic languages (such as
> inlining, type specialization, inline caches, object unboxing) don't
> seem to depend on the C API at all.

These are optimizations typically talked about in papers about dynamic
languages in general.  In my opinion, in the specific case of CPython,
they are all secondary to the following: (1) JIT, (2) GC, (3) object
model, (4) multithreading.

Currently, the C API only allows Psyco-style JITting (much slower than
PyPy).  All three other points might not be possible at all without a
seriously modified C API.  Why?  I have no proof, but only
circumstantial evidence.  Each of (2), (3), (4) has been done in at
least one other implementation: PyPy, Jython and IronPython.  Each of
these implementation has also got its share of troubles with emulating
the CPython C API.  You can continue to think that the C API has got
nothing to do with it.  I tend to think the opposite.  The continued
absence of major performance improvements for either CPython itself or
for any alternative Python implementation that *does* support the C
API natively is probably proof enough---I think that enough time has
passed, by now, to make this argument.

A bientôt,


More information about the Python-Dev mailing list