diff --git a/README.md b/README.md index f594dcf..48f77b6 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,8 @@ Call the same Fibonacci function from Python through [CFFI](https://cffi.readthe Install [uv](https://docs.astral.sh/uv/getting-started/installation/), a C/C++17 compiler, Rust with Cargo, and the zlib development headers. The default interpreter is CPython 3.15. Platform-specific -instructions are in the [getting-started guide](docs/index.md). +instructions are in the +[getting-started guide](https://tleonhardt.github.io/Python_Interface_Cpp/#install-the-toolchain). ```sh uv sync --locked @@ -37,17 +38,18 @@ samples of one million calls. Speedup is relative to pure Python on the same mac | Implementation | Median ns/call | Speedup vs. Python | | ---------------- | -------------: | -----------------: | -| Python | 219.0 | 1.00× | -| CFFI (ABI) | 107.5 | 2.04× | -| Cython (wrapper) | 21.4 | 10.21× | -| Cython (typed) | 21.2 | 10.35× | -| SWIG | 30.6 | 7.17× | -| pybind11 | 39.4 | 5.56× | -| nanobind | 23.6 | 9.28× | -| PyO3 | 25.9 | 8.44× | +| Python | 219.0 | 1.0× | +| CFFI (ABI) | 107.5 | 2.0× | +| Cython (wrapper) | 21.4 | 10.2× | +| Cython (typed) | 21.2 | 10.4× | +| SWIG | 30.6 | 7.2× | +| pybind11 | 39.4 | 5.6× | +| nanobind | 23.6 | 9.3× | +| PyO3 | 25.9 | 8.4× | To generate this table on your machine, run the following from the repository root after setup. See -the [benchmark guide](docs/benchmark.md) for how the calls are timed and how to change the workload. +the [benchmark guide](https://tleonhardt.github.io/Python_Interface_Cpp/benchmark/) for how the +calls are timed and how to change the workload. ```sh uv run --locked python -m comparison.benchmark --markdown -n 20 --calls 1000000 --repeat 9 @@ -59,9 +61,10 @@ uv run --locked python -m comparison.benchmark --markdown -n 20 --calls 1000000 declarations and the native functions they call. - [Rust extension](rust/) uses PyO3 and maturin. It exposes the same Python function as the C and C++ examples. -- [The guide to the bindings](docs/bindings.md) explains when each approach fits. - [Workshop exercises](docs/exercises.md) cover typed loops, buffers, vectors, callbacks, and - passing Python sequences to Rust with PyO3. +- [The guide to the bindings](https://tleonhardt.github.io/Python_Interface_Cpp/bindings/) explains + when each approach fits. + [Workshop exercises](https://tleonhardt.github.io/Python_Interface_Cpp/exercises/) cover typed + loops, buffers, vectors, callbacks, and passing Python sequences to Rust with PyO3. The original [slides](Interfacing_C_C++_with_Python.pdf) and [lab handout](Interfacing_C_C++_with_Python-Exercises.pdf) accompany the diff --git a/comparison/benchmark.py b/comparison/benchmark.py index d0d9b54..b1a652a 100644 --- a/comparison/benchmark.py +++ b/comparison/benchmark.py @@ -33,7 +33,7 @@ def main() -> None: print() print("| Implementation | Median ns/call | Speedup vs. Python |") print("| --- | ---: | ---: |") - row = "| {name} | {ns:.1f} | {speedup:.2f}× |" + row = "| {name} | {ns:.1f} | {speedup:.1f}× |" else: print(f"{'Implementation':<18} {'ns/call':>10} {'speedup':>9}") row = "{name:<18} {ns:>10.1f} {speedup:>8.2f}x"