Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Strided memoryview cast #2563
Would be nice if one could cast something to a strided memoryview with non-trivial striding. This is basically an extension of casting a pointer to a memoryview.
cdef np.ndarray[float, ndim=1] a = np.empty((10,), dtype=np.float32)[::2] cdef a_v = <floating[:a.shape:a.strides]>&a.data
Note: In reality
This would be hard because there are other operations such as "shape" that ndarrays are expected to have, and it can be used in an object-like context. If you have a pointer that you want to use in this manner, use the numpy APIs for wrapping bare (unmanaged) pointers in ndarray objects.
It might be more possible to create a fake memory view of a pointer, but still a bit iffy.