Message334742
It seems reasonable to support f-contiguous for cast() and tobytes().
For tobytes() it's implemented in the issue that Antoine linked to.
General support for strides in cast(), i.e. a zero-copy view for
non-contiguous arrays does not seem possible because buf.ptr is
moved around. Even NumPy does not support that:
>>> x = np.array([1,2,3])
>>> x.view('B')
array([1, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0,
0, 0], dtype=uint8)
>>>
>>> x[::-1].view('B')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: To change to a dtype of a different size, the array must be C-contiguous
>>>
>>> y = x.astype('B')
>>> y.flags['OWNDATA'] # It's a copy.
True |
|
Date |
User |
Action |
Args |
2019-02-02 10:23:57 | skrah | set | recipients:
+ skrah, ncoghlan, pitrou, lgautier, mattip |
2019-02-02 10:23:55 | skrah | set | messageid: <1549103035.72.0.161097989982.issue34778@roundup.psfhosted.org> |
2019-02-02 10:23:55 | skrah | link | issue34778 messages |
2019-02-02 10:23:55 | skrah | create | |
|