Skip to content
This repository was archived by the owner on Mar 25, 2025. It is now read-only.

Move from pybind11 to nanobind + raw C API #1539

@JCGoran

Description

@JCGoran

From an internal discussion:

In NMODL we use pybind11 to achieve 2 things:

a) making a Python wrapper for (some of the) C++ API
b) embedding the interpreter

For b) we actually just call our hand-made Python script for solving systems of equations using SymPy, and nothing else. Since in NEURON we are using nanobind for a), I think it would make sense to just port a) to nanobind, and use the Python C API directly for b) (since nanobind does not support embedding the interpreter). The benefits of this switch are two-fold:

  • once we integrate NMODL into NEURON, we don’t need to keep track of two libraries, but only one (nanobind is anyway smaller and more performant)
  • pybind11 does not support the Python limited C API (which has guaranteed ABI stability), which means that, until we remove pybind11, we need to build wheels for every single minor version of Python. On the other hand, nanobind supports the limited API since 3.12, so at least the Python wheels would be more or less future-proof (so we’d only need to build wheels on one Python version, i.e. the oldest one supported)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions