RobotLocomotion / drake

Model-based design and verification for robotics.
https://drake.mit.edu
Other
3.16k stars 1.24k forks source link

Switch pydrake bindings from pybind11 to nanobind #21572

Open jwnimmer-tri opened 2 weeks ago

jwnimmer-tri commented 2 weeks ago

Is your feature request related to a problem? Please describe.

Drake's pydrake bindings layer is a pain point in various ways:

The former is annoying not only for build times, but also because it takes up way more space on PyPI per release, which leads to things like https://github.com/pypi/support/issues/3226 where we burn through our quota 3-4x faster than we should be doing. Ideally, our bindings library should support Python's Stable API, also know as abi3.

Describe the solution you'd like

Port pydrake to use nanobind instead of pybind11.

Describe alternatives you've considered

There are various other pybind11-inspired bindings libraries, but none of them seem to support abi3.

Additional context

My current thinking is that the first step should be https://github.com/RobotLocomotion/drake/pull/19250, i.e., removing all of Drake's customization of pybind11. After that, we can follow https://nanobind.readthedocs.io/en/latest/porting.html to move from vanilla pybind11 to nanobind.