benbovy / spherely

Manipulation and analysis of geometric objects on the sphere.
https://spherely.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
119 stars 8 forks source link

Investigate nanobind in place of pybind11 #19

Closed brendan-ward closed 1 week ago

brendan-ward commented 1 year ago

@benbovy feel free to close this if you are already aware of it and didn't want to consider it. I'm hoping to carve out a little time at some point to see what it might take to switch and whether or not it would be helpful; don't feel this issue is an obligation for you to do so.

nanobind is effectively a newer, smaller, lighter weight replacement of pybind11; the why page helps explain why it was created. The core API is very similar to pybind11 but at present is a bit less full-featured (which is partly a good thing). It targets a narrower range of C++ (17+) and Python (3.8+) versions. The potential downsides are that it is newer and less-full featured, and hasn't yet accumulated lots of GH issues / stack overflow posts around less common situations, compared to pybind11 (though these may not matter).

I'm not yet sure if the ndarray interface in nanobind would make some of the challenges around numpy and dtypes easier or harder.

I recently ported a small library from pybind11 to nanobind, and overall the experience was smooth and produced wheel files that were a little smaller (did not benchmark compile or runtime timings).

benbovy commented 1 year ago

@brendan-ward thanks for opening this issue. Nanobind has been briefly discussed in various places but it is better to gather the discussion here. Also good to know that the transition from pybind11 to nanobind went smoothly in your case.

A few thoughts:

benbovy commented 3 months ago

One thing that currently prevents us using nanobind here is that it doesn't supports arbitrary Python objects as numpy array items.

benbovy commented 1 week ago

I'm closing this issue since nanobind doesn't seem to have a plan for adding support of numpy arrays with arbitrary Python objects anytime soon. Let's re-open it if that changes.