[Python] How can I convert a nb::handle (or nb::object or PyObject*) into a nb::ndarray?

Discussão em 'Python' iniciado por Stack, Maio 20, 2025.

  1. Stack

    Stack Membro Participativo

    Nanobind has a function nb::ndarray_check(handle h) which returns true in case h is usable as an ndarray (e.g. if it implements the buffer protocol).

    How do I actually create an instance of nb::ndarray from h?

    nb::ndarray has a constructor explicit ndarray(detail::ndarray_handle *handle). But there seems to be none which takes a simple PyObject*, nb::handle, or nb::eek:bject as an argument.

    Continue reading...

Compartilhe esta Página