Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move from pybind11 to nanobind + raw C API #1539

Open
JCGoran opened this issue Oct 28, 2024 · 0 comments
Open

Move from pybind11 to nanobind + raw C API #1539

JCGoran opened this issue Oct 28, 2024 · 0 comments

Comments

@JCGoran
Copy link
Contributor

JCGoran commented Oct 28, 2024

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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant