Arrays and tensors¶
xtensor-python provides two container types wrapping numpy arrays:
pytensor. They are the counterparts
pyarray has a dynamic shape. This means that you can reshape the numpy array on the C++ side and see this
change reflected on the python side.
pyarray doesn’t make a copy of the shape or the strides, but reads them each time it
is needed. Therefore, if a reference on a
pyarray is kept in the C++ code and the corresponding numpy array is then reshaped
in the python code, this modification will reflect in the
pytensor has a static stack-allocated shape. This means that the shape of the numpy array is copied into
the shape of the
pytensor upon creation. As a consequence, reshapes are not reflected across languages. However, this drawback
is offset by a more effective computation of shape and broadcast.