Skip to content

feat: Switch to using nanobind from pybind11 (!10)

Matthew Feickert requested to merge feat/use-nanobind-over-pybind11 into main

Now that there is a stable v1.0.0 release of nanobind, this MR follows the nanobind docs instructions on getting setup with nanobind and CMake and porting a pybind11 project to nanobind.

The main reasons that nanobind is attractive for the Columnar Analysis project are (in my mind):

More concretely, benchmarks show ~2-3× faster compile time, ~3× smaller binaries, and up to ~8× lower runtime overheads compared to pybind11.

nanobind can exchange n-dimensional arrays (henceforth “ndarrays”) with popular array programming frameworks including NumPy, PyTorch, TensorFlow, and JAX. It supports zero-copy exchange using two protocols:

nanobind knows how to talk to each framework and takes care of all the nitty-gritty details.

Both of those seem like big wins to me!

I also want to thank @gstark and (especially big thanks to) Angus Hollands for their help in debugging some small C++ things that I messed up over in the IRIS-HEP Slack (my C++-foo in my postdoc years had become quite degraded compared to my Ph.D. days 😬).


Edited by Matthew Feickert

Merge request reports