HPy 0.0.2 is out! This is the first version which is officially released and made available on PyPI.
The major highlight of this release is that it is supported by three different Python implementations: CPython, PyPy and GraalPython.
What is HPy?
HPy provides a new API for extending Python in C. In other words, you use
#include <hpy.h> instead of
#include <Python.h>. For more info, look at
HPy 0.0.2 only supports Linux systems, and it's only tested on
x86_64. Windows support is already present on master, and it will be
included in the next release.
For CPython, you need to install it manually, using pip:
$ pip install hpy==0.0.2
Currently, we provide only the
sdist (i.e., the
.tar.gz, no binary
wheels). See also
issue #223, contributions
are welcome :).
PyPy and GraalPython ships their own version of HPy, so no installation is necessary. HPy 0.0.2 will be included in the next release of both, i.e. PyPy 7.3.6 (expected in October 2021) and GraalPython 21.2.0 (expected on 2021-07-20). In the meantime, you can download a nightly build:
GraalPython: download the latest
graalpython-devpackage from this page
To double check the version of HPy which is shipped with those, you can either
$ pypy -m pip show hpy Name: hpy Version: 0.0.2 Summary: A better C API for Python Home-page: https://hpyproject.org Author: The HPy team Author-email: email@example.com License: MIT ... $ pypy -c 'import hpy.universal; print(hpy.universal.get_version())' 0.0.2
At the moment HPy supports only a small fraction of the full API offered by
the old Python/C API, but it is enough to write non-trivial extensions, and
the documentation is
which is used to autogenerate parts of the HPy code, is a reliable list of all
the supported functions.
The HPy API is still considered in alpha status and it's subject to change
between versions. In fact, the current master is already incompatible with
hpy-0.0.2 because of
PR #182, which renamed all
The best way to get a glimpse of how to use HPy is to look at examples:
the HPy repository contains a "proof of concept" package. Make sure to checkout the branch
ultrajson-hpyis a port of the popular
ultrajsonpackage. Make sure to checkout the
piconumpycontains a very tiny implementation of an
array-like class. Make sure to checkout the