How wjakob/nanobind works
Project type and purpose
• nanobind is a C++ library for creating Python bindings. It exposes C++ types/functions to Python via a thin header-only API plus a small runtime core library.
• It ships as a Python package (PyPI) and supports CMake and Bazel build systems.
File structure
• Top-level directories:
• /nanobind → public headers (the binding API)
• src → core C++ implementation, small Python helper scripts (stubgen.py, version.py, __main__.py)
• ext/robin_map → third-party submodule for efficient hash maps
• cmake/ & CMakeLists.txt, .gitmodules → build scripts and configuration for CMake (and spinnable to Bazel)
• tests → C++ (Google Test) and Python (pytest) test suites exercising bindings
• docs → Sphinx documentation source
• Build artifacts: shared libraries (.so/.pyd) generated by CMake/Bazel
• Packaging: pyproject.toml defines Python packaging metadata
README for additional insights
• Emphasizes performance: faster compile times, smaller binaries, lower runtime overhead vs. pybind11 and Cython
• Highlights core features: header-only syntax, near-identical API to pybind11, cross-interpreter support (CPython & PyPy)