Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

cppjit: automatic Python-C++ interop and bindings

CI Nightlies Wheels Python License

cppjit embeds an interactive C++ JIT compiler in Python: write or import C++ at run time and use its functions, classes, and templates as if they were Python. In contrast to binding libraries such as pybind11 and nanobind, there is no wrapper code to write and no CMake build to set up: bindings materialize automatically on demand, derived from the C++ declarations. Run-time binding generation enables:

  • Detailed specialization of each call at the point of use
  • Lazy loading for reduced memory use in large-scale projects
  • Python-side cross-inheritance and callbacks for working with C++ frameworks
  • Run-time template instantiation, so the binding surface never has to be enumerated ahead of time
  • Automatic object downcasting and exception mapping
  • Interactive exploration of C++ libraries from the Python prompt

cppjit supports user-developed C++ frameworks and third-party C++ libraries from standard package managers, and lets you use them from a Python application or build a Python-based DSL on top. cppjit is the successor project of cppyy, rebuilt on CppInterOp and the clang-repl C++ interpreter in LLVM. See the CHEP 2026 and the EuroLLVM 2026 talks for more details.

Examples

A CPython extension builds Python proxies for all C++ entities: functions, classes, templates, and variables. Constructors, operators, and data members follow Python conventions. The embedded JIT lazily compiles the C++ behind each proxy:

import cppjit

cppjit.cppdef("""
struct Vec2 {
    double x, y;
    Vec2 operator+(const Vec2& o) const { return {x + o.x, y + o.y}; }
};""")

c = cppjit.gbl.Vec2(1, 2) + cppjit.gbl.Vec2(3, 4)
c.x, c.y                 # (4.0, 6.0)

Templates instantiate on demand, and STL containers behave like Python containers:

cppjit.cppdef("""
#include <algorithm>
template <typename T>
T largest(const std::vector<T>& xs) { return *std::max_element(xs.begin(), xs.end()); }
""")

v = cppjit.gbl.std.vector['int']([3, 1, 4, 1, 5])
cppjit.gbl.largest(v)    # 5; largest<int> is compiled at this call
len(v), list(v)          # vectors support len(), iteration, indexing

Python callables pass into C++ as function pointers:

cppjit.cppdef("""
template <typename R, typename... U, typename... A>
R callme(R (*f)(U...), A &&...args) {
  return f(args...);
}""")

def callback(x: int, y: float) -> float:
    return x + y

cppjit.gbl.callme(callback, 123, 321.5)   # 444.5

NumPy arrays pass zero-copy; the C++ side works on the same buffer:

import numpy as np
a = np.arange(6, dtype=np.float64)

cppjit.cppdef("void scale(double* xs, std::size_t n, double f) { while (n--) xs[n] *= f; }")
cppjit.gbl.scale(a, a.size, 10.0)
a                        # array([ 0., 10., 20., 30., 40., 50.]); same buffer, no copy

An installed library binds at run time, with no binding code written for it:

import cppjit
cppjit.include('zlib.h')          # bring in the declarations
cppjit.load_library('libz')       # load the symbols
cppjit.gbl.zlibVersion()          # '1.3'; call the library directly

CppInterOp drives Clang and provides the necessary run-time reflection and JIT compilation API for cppjit.

Use cases

  • Numerics and data science: move performance-critical code into C++ in the same session.
  • Template-heavy APIs: STL, Eigen, and user templates instantiate lazily at call sites.
  • Existing C++ codebases: use them from Python without modification.
  • Domain-specific languages: user-defined "pythonizations" adapt the bindings into Pythonic libraries.

Requirements

A package manager installation of cppjit (such as pip) requires GCC >= 9 or Clang >= 15 (the JIT compiles C++ against the host's standard library headers).

Building from source requires:

  • LLVM/Clang development packages, version 21 or 22
  • Python 3.12+ with development headers
  • CMake 3.20+
  • A C++20 compiler: g++ 13+, or a Clang matching the LLVM major (an older Clang fails to compile newer LLVM headers)
  • CppInterOp, cloned at build time or supplied from a local checkout (see the development builds below)

Source installation (pip)

Ubuntu 24.04
sudo apt-get update
sudo apt-get install -y git cmake make g++ python3-dev python3-venv python3-pip \
    wget lsb-release software-properties-common gnupg libzstd-dev libedit-dev
wget https://apt.llvm.org/llvm.sh && sudo bash llvm.sh 21
sudo apt-get install -y llvm-21-dev libclang-21-dev clang-21 libpolly-21-dev

python3 -m venv venv && source venv/bin/activate
git clone https://github.com/compiler-research/cppjit.git && cd cppjit
pip install -v . --config-settings=cmake.define.LLVM_DIR=/usr/lib/llvm-21/lib/cmake/llvm
macOS
brew install llvm@21 cmake ninja
python3 -m venv venv && source venv/bin/activate
git clone https://github.com/compiler-research/cppjit.git && cd cppjit
pip install -v . --config-settings=cmake.define.LLVM_DIR="$(brew --prefix llvm@21)/lib/cmake/llvm"

Development build (pip editable)

With the toolchain from the source installation above, an editable install with a persistent build directory gives incremental rebuilds:

export LLVM_DIR=/usr/lib/llvm-21/lib/cmake/llvm   # your LLVM's CMake directory
pip install scikit-build-core
pip install --no-build-isolation -ve . \
    --config-settings=build-dir=build \
    --config-settings=cmake.define.LLVM_DIR=$LLVM_DIR

To co-develop both CppInterOp and cppjit, clone CppInterOp next to cppjit and rerun the install with a separate build directory and --config-settings=cmake.define.CPPINTEROP_SOURCE_DIR=$PWD/../CppInterOp. The local checkout overrides the pinned tag, so new CppInterOp API is usable from cppjit immediately.

Development build (CMake)

The CMake build compiles and stages CppInterOp inside the build tree and assembles the Python package under <build>/python; point PYTHONPATH there instead of installing:

export LLVM_DIR=/usr/lib/llvm-21/lib/cmake/llvm   # your LLVM's CMake directory
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DLLVM_DIR=$LLVM_DIR
cmake --build build -j
export PYTHONPATH=$PWD/build/python

A prebuilt CppInterOp (built shared with -DBUILD_SHARED_LIBS=ON and installed to a prefix) is consumed in place through CppInterOp_DIR instead of being rebuilt:

cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DLLVM_DIR=$LLVM_DIR \
    -DCppInterOp_DIR=$PWD/../CppInterOp/install/lib/cmake/CppInterOp

Running the test suite locally

pip install -r requirements.txt
cd test
make -j4                          # builds the *Dict.so loaded for tests
python -m pytest -ra --tb=short

Contributing

Bug reports, feature requests, and questions go to the issue tracker. Pull requests are welcome; run the test suite before submitting.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cppjit-0.1.0a1.tar.gz (416.3 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

cppjit-0.1.0a1-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (51.8 MB view details)

Uploaded CPython 3.14manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

cppjit-0.1.0a1-cp314-cp314-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl (48.5 MB view details)

Uploaded CPython 3.14manylinux: glibc 2.27+ ARM64manylinux: glibc 2.28+ ARM64

cppjit-0.1.0a1-cp314-cp314-macosx_14_0_x86_64.whl (36.4 MB view details)

Uploaded CPython 3.14macOS 14.0+ x86-64

cppjit-0.1.0a1-cp314-cp314-macosx_14_0_arm64.whl (34.2 MB view details)

Uploaded CPython 3.14macOS 14.0+ ARM64

cppjit-0.1.0a1-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (51.8 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

cppjit-0.1.0a1-cp313-cp313-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl (48.5 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.27+ ARM64manylinux: glibc 2.28+ ARM64

cppjit-0.1.0a1-cp313-cp313-macosx_14_0_x86_64.whl (36.4 MB view details)

Uploaded CPython 3.13macOS 14.0+ x86-64

cppjit-0.1.0a1-cp313-cp313-macosx_14_0_arm64.whl (34.2 MB view details)

Uploaded CPython 3.13macOS 14.0+ ARM64

cppjit-0.1.0a1-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (51.8 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

cppjit-0.1.0a1-cp312-cp312-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl (48.5 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.27+ ARM64manylinux: glibc 2.28+ ARM64

cppjit-0.1.0a1-cp312-cp312-macosx_14_0_x86_64.whl (36.4 MB view details)

Uploaded CPython 3.12macOS 14.0+ x86-64

cppjit-0.1.0a1-cp312-cp312-macosx_14_0_arm64.whl (34.2 MB view details)

Uploaded CPython 3.12macOS 14.0+ ARM64

File details

Details for the file cppjit-0.1.0a1.tar.gz.

File metadata

  • Download URL: cppjit-0.1.0a1.tar.gz
  • Upload date:
  • Size: 416.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for cppjit-0.1.0a1.tar.gz
Algorithm Hash digest
SHA256 ebda4a4574e1a93e5c30ab7a49365c411fd2580716d5a73aac5de0de1c127bf0
MD5 2b57672b70bdf59ca860a80f7e43a00b
BLAKE2b-256 943bc0b443e316841d63ca4990d70845d17267dab1f58cb090a28a13e6aba4d4

See more details on using hashes here.

Provenance

The following attestation bundles were made for cppjit-0.1.0a1.tar.gz:

Publisher: pypi.yml on compiler-research/cppjit

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file cppjit-0.1.0a1-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for cppjit-0.1.0a1-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 2fe951e4219b61e79c60cf5fdf00c5e00121235dbea8a1d33a7886938cf57e75
MD5 5fe4dc666b4a2f02e87765c0ae1c643f
BLAKE2b-256 28ad3061e70e2385a40d67173dca8b7c1afb036957ab0741b016156f76c12730

See more details on using hashes here.

Provenance

The following attestation bundles were made for cppjit-0.1.0a1-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl:

Publisher: pypi.yml on compiler-research/cppjit

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file cppjit-0.1.0a1-cp314-cp314-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for cppjit-0.1.0a1-cp314-cp314-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 b3c90266c5b6f3e157b4f8180f5c569322e8361ed6bad0e749014626dd2b46cf
MD5 2b2a966863e7d1509194fda74be17e79
BLAKE2b-256 895d3b9a43cb15749a2df44534f82b96aa251e8b130eb2c114854e791e66b14b

See more details on using hashes here.

Provenance

The following attestation bundles were made for cppjit-0.1.0a1-cp314-cp314-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl:

Publisher: pypi.yml on compiler-research/cppjit

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file cppjit-0.1.0a1-cp314-cp314-macosx_14_0_x86_64.whl.

File metadata

File hashes

Hashes for cppjit-0.1.0a1-cp314-cp314-macosx_14_0_x86_64.whl
Algorithm Hash digest
SHA256 b124ef3788eec1e11f050e9165a0f0be7bbfdf2c219b09f474b3c4e2bd1549fc
MD5 8f0d9934c924de74adc237fcb7000486
BLAKE2b-256 a7cd2ea8a7cbe8bda8b3d771459691bf26bdea110e1c10513f2e93a3b8a174d1

See more details on using hashes here.

Provenance

The following attestation bundles were made for cppjit-0.1.0a1-cp314-cp314-macosx_14_0_x86_64.whl:

Publisher: pypi.yml on compiler-research/cppjit

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file cppjit-0.1.0a1-cp314-cp314-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for cppjit-0.1.0a1-cp314-cp314-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 c955e6b7345ad414e1fb8a1c4b280bb421e523308a40f99586a701962351061c
MD5 f0cc73457dd5ba09dea912166de7fd1a
BLAKE2b-256 28852af20b6c6d117a78d614c32659ea853adf75c3a36556ad340de351ad047a

See more details on using hashes here.

Provenance

The following attestation bundles were made for cppjit-0.1.0a1-cp314-cp314-macosx_14_0_arm64.whl:

Publisher: pypi.yml on compiler-research/cppjit

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file cppjit-0.1.0a1-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for cppjit-0.1.0a1-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 14b115e0a8da35f9b9908f2056e8a38ba84708cb22726808ddd2953d3564e665
MD5 6df988ed65f3402aa62b8229bb314a48
BLAKE2b-256 f984c43ff2490b8492daf1cb3bb8e9ab13053e86ea73e11c97457d22bdaf322b

See more details on using hashes here.

Provenance

The following attestation bundles were made for cppjit-0.1.0a1-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl:

Publisher: pypi.yml on compiler-research/cppjit

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file cppjit-0.1.0a1-cp313-cp313-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for cppjit-0.1.0a1-cp313-cp313-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 42db21675b78e53364acc37c3dfefd0b4738c9d063b623f5c30c13daa48961b4
MD5 43c6b1470f373a6e6a0049b48a2244e8
BLAKE2b-256 12d64051cdb969e0d364cf1a076f85eb1c6b78d0963741f3af88e96952e58418

See more details on using hashes here.

Provenance

The following attestation bundles were made for cppjit-0.1.0a1-cp313-cp313-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl:

Publisher: pypi.yml on compiler-research/cppjit

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file cppjit-0.1.0a1-cp313-cp313-macosx_14_0_x86_64.whl.

File metadata

File hashes

Hashes for cppjit-0.1.0a1-cp313-cp313-macosx_14_0_x86_64.whl
Algorithm Hash digest
SHA256 d393e5220083ee7b3c4fd8fad88545a3a85a85416b1c712a7100f264058d37c9
MD5 74986a78f8489cc1be2a4995e9c5c749
BLAKE2b-256 47ebd52341fa84e381186eaf07b3e1fef0c2d0ef2188e435152c900a1f4853b0

See more details on using hashes here.

Provenance

The following attestation bundles were made for cppjit-0.1.0a1-cp313-cp313-macosx_14_0_x86_64.whl:

Publisher: pypi.yml on compiler-research/cppjit

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file cppjit-0.1.0a1-cp313-cp313-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for cppjit-0.1.0a1-cp313-cp313-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 b04dd5545db70f5580e153b9837a597ef0255baab76efbb6a42fa2b003f00099
MD5 2fb6136fe9f54ef4cac83b90fd1f4034
BLAKE2b-256 43589be02cf6479fd68fc2670384baeb8b3603e3dba58f076ea24aa95e47855e

See more details on using hashes here.

Provenance

The following attestation bundles were made for cppjit-0.1.0a1-cp313-cp313-macosx_14_0_arm64.whl:

Publisher: pypi.yml on compiler-research/cppjit

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file cppjit-0.1.0a1-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for cppjit-0.1.0a1-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 23c0be62fe1edc483d9027bbca76233963005c5c4a1e651f27c9edbd4b58c313
MD5 e46420c7ae0d335aad148f166a89487a
BLAKE2b-256 8d49bc8acc6db1cfc4fb960954638492ce93f1c8eaf7e031adc2c2db07127a7c

See more details on using hashes here.

Provenance

The following attestation bundles were made for cppjit-0.1.0a1-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl:

Publisher: pypi.yml on compiler-research/cppjit

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file cppjit-0.1.0a1-cp312-cp312-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for cppjit-0.1.0a1-cp312-cp312-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 b30f6f68977d83adebc7c739ea4fedbf65f30fdbf2e78243b0d435ae6afd42e8
MD5 d655bb0ccf0d53cd05e71268113d5774
BLAKE2b-256 5cf0eb0dfe27b53dc21501ba4b2afe3fefd0628ff2fd92ae748d0fb2d79a73d4

See more details on using hashes here.

Provenance

The following attestation bundles were made for cppjit-0.1.0a1-cp312-cp312-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl:

Publisher: pypi.yml on compiler-research/cppjit

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file cppjit-0.1.0a1-cp312-cp312-macosx_14_0_x86_64.whl.

File metadata

File hashes

Hashes for cppjit-0.1.0a1-cp312-cp312-macosx_14_0_x86_64.whl
Algorithm Hash digest
SHA256 d8b1406819a7a4a2c34b5fca7e690333699507dd846e41aa68f374eeef0d3e75
MD5 6d35080e2fb1889dc39167aa470896a2
BLAKE2b-256 098a52ff1ee526056b55de45c125d943b30cbbf16060e199a26ebe10aff3d97d

See more details on using hashes here.

Provenance

The following attestation bundles were made for cppjit-0.1.0a1-cp312-cp312-macosx_14_0_x86_64.whl:

Publisher: pypi.yml on compiler-research/cppjit

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file cppjit-0.1.0a1-cp312-cp312-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for cppjit-0.1.0a1-cp312-cp312-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 76bbefa957209f86e89903be37bb021d1a6849754466c9da98f427b025d90fd3
MD5 05ae8a253a55e90e5cacda73ee3ab02b
BLAKE2b-256 cf42d6984ead067d5840d164ccf0b2ff68758c8c8ab021cab566629232cdecf3

See more details on using hashes here.

Provenance

The following attestation bundles were made for cppjit-0.1.0a1-cp312-cp312-macosx_14_0_arm64.whl:

Publisher: pypi.yml on compiler-research/cppjit

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

0.1.0a1 This release

13 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page