Possible for nanobind to support Awkward arrays? #2350
Replies: 2 comments 2 replies
-
@matthewfeickert would you be able to elaborate upon what you'd like to be able to do here? With Awkward 2, nearly all of Awkward Array is implemented in Python. We have some performance logic (C++ kernels, As such, I'm not sure what a nanobind interface would look like, or offer to the user. For regular arrays, it would be possible to convert their layouts to e.g. We could add support for DLPack (which is a todo item) that would succeed only for regular arrays. That's an agenda item that I've not spoken much to @jpivarski about yet :) |
Beta Was this translation helpful? Give feedback.
-
I've been thinking, and have mentioned a few times, that Awkward could possibly replace its pybind11 bindings with nanobind bindings, only because we don't use very much of pybind11's features and can perhaps simplify things, get smaller binaries, and maybe have faster start-up times and call overhead. A few features still use the C++ interface, such as ArrayBuilder, JSON I/O, and AwkwardForth. The kernel functions, which are a much larger fraction of Awkward's functionality, are called through ctypes, not pybind11, and it's unclear to me whether there would be an advantage to generating and compiling nanobind interfaces for all of them, too. But that's an entirely internal change, and not high on any priority list. It wouldn't be seen from the outside. I agree with @agoose77 in not seeing any benefit to having a special interface to nanobind's (By the way, we used to use DLPack to deal with CUDA array buffers in Awkward v1—as an internal implementation—but we don't have to anymore because we let CuPy deal with the interface between Python and C++, in analogy with NumPy and C. Presumably, CuPy uses DLPack.) Basically, we now live one layer higher in abstraction. We don't have C or C++ interfaces, but the libraries we use do. And if you want to get nested structure/jagged arrays between languages, that's what Arrow is for, and that's why we have a lightweight |
Beta Was this translation helpful? Give feedback.
-
This is not a discussion about asking if Awkward has any plans to switch to using
nanobind
overpybind11
— that's a separate discussion that I don't want to force on the team now. This is a question that is based out of my own ignorance of how things work on if the Awkward team thinks there should be any reason thatnanobind
couldn't support Awkward in the same way that is supports other n-dimensional arrays through thenanobind::ndarray
API.With the release of
nanobind
v1.0.x
, the "Thenb::ndarray<..>
class" docs mentionwhich seems to be in contrast with the
pybind11
docs on integration with NumPy arrays that only discuss NumPy.While this is really a question that needs to be put to the
nanobind
team, does the Awkward team see any technical reason why the list of n-dimensional arrays thatnanobind
can exchange with in a zero-copy way couldn't also in the future include Awkward?Beta Was this translation helpful? Give feedback.
All reactions