PyCon UK 2022

HPy: a better C API for Python
09-17, 12:30–13:00 (Europe/London), Assembly Room

HPy is a new C API for Python. Unlike the standard one, it isn't tied to CPython implementation details. It is therefore fully compatible with alternate implementations and with any future changes to CPython itself.


The official Python C API is specific to the current implementation of CPython. It has served us well and forms the basis upon which our entire extension ecosystem rests.
However, it exposes a lot of internal details which makes it hard to implement it for other Python implementations (e.g. PyPy, GraalPython, Jython, IronPython, etc.), and
prevents major evolutions of CPython itself, such as using a GC instead of refcounting, or removing the GIL.

This is where HPy comes in. It's a new C API designed from the ground up according to the following goals:
* running much faster on alternate implementations, and at native speed on CPython
* making it possible to compile a single binary which runs unmodified on all supported Python implementations and versions
* being simpler and more manageable than the Python/C API
* providing an improved debugging experience.

We'll discuss its current status and show how existing extensions can be gradually ported to it.

I'm a freelance software developer and open-source consultant. I'm a cofounder of HPy and I've been a PyPy core developer since 2012.