Skip to content

Alternative to buffer protocol #478

Answered by wjakob
awni asked this question in Q&A
Mar 16, 2024 · 1 comments · 1 reply
Discussion options

You must be logged in to vote

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.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@awni
Comment options

Answer selected by awni
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants