You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We intend to switch the C/C++ extension build system to use pybind11 as discussed in this week's call. There is a demonstration in PR #23787 showing that the approach works and listing the pros and cons. It is too much work to do in a single PR so will probably be done one extension at a time. This issue is intended to track the overall progress by editing this post to tick the relevant check box and add the PR number for each extension completed.
As this project is array heavy nanobin is super nice for this as it allows you to just use the nb::ndarray API and avoid all the buffer stuff in pybind11 (which honestly isn't that bad, but if you don't have to do it yourself that's great).
Other advantages that are nice about nanobind (YMMV though project to project):
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:
I'm not sure about this one, as it doesn't use NumPy, and is written in Objective C, not C or C++.
I agree pybind doesn't seem like the right fit. I have wondered if it'd be worthwhile to transition to use pyobjc at all so we could write the extension in Python code... https://pyobjc.readthedocs.io/en/latest/
Of course, that would mean an extra dependency on macos and needing to learn how to write that style of Python.
Activity
QuLogic commentedon Mar 30, 2023
On a related note, has anyone tried out nanobind? It's probably a bit too new for us, but curious if anyone had any opinions on it.
matthewfeickert commentedon Mar 30, 2023
I just today migrated a (small) research project to
nanobinv1.0.0.As this project is array heavy
nanobinis super nice for this as it allows you to just use thenb::ndarrayAPI and avoid all the buffer stuff inpybind11(which honestly isn't that bad, but if you don't have to do it yourself that's great).Other advantages that are nice about
nanobind(YMMV though project to project):My first impressions are that it is great!
QuLogic commentedon Oct 5, 2023
I'm not sure about this one, as it doesn't use NumPy, and is written in Objective C, not C or C++.
greglucas commentedon Oct 6, 2023
I agree pybind doesn't seem like the right fit. I have wondered if it'd be worthwhile to transition to use pyobjc at all so we could write the extension in Python code... https://pyobjc.readthedocs.io/en/latest/
Of course, that would mean an extra dependency on macos and needing to learn how to write that style of Python.
QuLogic commentedon Sep 6, 2024
The last PR #28785 does ft2font. After that there will be some clean up to remove the NumPy wrappers.
QuLogic commentedon Sep 24, 2024
The last two PRs: #28856 takes care of porting remaining common functionality to pybind11, and #28857 removes NumPy and the helpers.