xtensor-stack / xtensor-python

Python bindings for xtensor
BSD 3-Clause "New" or "Revised" License
345 stars 58 forks source link

xtensor-python in reverse: pyarray_view and pytensor_view? #311

Open matwey opened 1 month ago

matwey commented 1 month ago

Hello,

I suppose it is a feature request.

I want to call a python function provided by a user from my C++ code. The function argument is numpy array the function result is numpy array as well. Yet it is obviously not possible to call this function lazily with xtensor code, I would like to provide xtensor or xarray as is to python side. Generally, it is possible via buffer protocol. It think it can be implemented using helpers pyarray_view<XContainer> and pytensor_view<XContainer>.