Skip to main content

HPy: The Future of Python Native Extensions

30 minutes


Updating Python versions often forces us to update native extensions at the same time. But what if you need to update Python because of a security issue, but cannot (yet) move to a newer version of a dependency? Or you are running a proprietary binary extension that cannot easily be recompiled?

The HPy project provides a better C extension API for Python. It compiles to binaries that work across all versions of CPython, PyPy, GraalPy. HPy makes porting from the existing C API easy and its design ensures that the binaries we produce today stay binary compatible with future Python versions.

NumPy is the single largest direct user of the CPython C API we know of. After over 2 years of work and more than 30k lines of code ported, we can demonstrate NumPy running its tests and benchmarks with HPy. We will show the same NumPy binary run on multiple CPython versions and GraalPy. And we will discuss performance characteristics of this port across CPython, GraalPy, and PyPy.

TalkPython Internals & Ecosystem

The speakers

Tim Felgentreff

I am a member of the GraalVM team at Oracle Labs. I was led here by my interests in programming languages and virtual machine design, and my involvement with the PyPy/RPython project and various other dynamic language VMs. My work revolves around dynamic language interoperability, connecting them with native C code in a safe manner, and providing cross-language tool support. I also continue to collaborate with the Hasso Plattner Institute at the University of Potsdam on tools and environments for dynamic languagues and polyglot programming.

Florian Angerer

Florian Angerer is member of the Graal project at Oracle Labs and works on GraalPy, a fast, Java-based implementation of Python. He is also core developer of HPy, a new API for extending Python in C. He received his Ph.D. in Computer Science from the Johannes Kepler University Linz, Austria.