-
We are evaluating switching MLX from Pybind11 to Nanobind (ml-explore/mlx#839) The
However, nanobind does not have the same support for the buffer protocol. I am wondering if there is a recommended approach to achieve the same as above? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Please see this part of the documentation: https://nanobind.readthedocs.io/en/latest/typeslots.html You should be able to add custom slots recreate the pybind11 behavior if you truly want your object to expose the native buffer protocol. What I think would be much easier is to add an |
Beta Was this translation helpful? Give feedback.
Please see this part of the documentation: https://nanobind.readthedocs.io/en/latest/typeslots.html
You should be able to add custom slots recreate the pybind11 behavior if you truly want your object to expose the native buffer protocol. What I think would be much easier is to add an
__array__
method to your class, which NumPy will accept as well.