This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author skrah
Recipients lgautier, mattip, ncoghlan, pitrou, skrah
Date 2019-02-02.10:23:55
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1549103035.72.0.161097989982.issue34778@roundup.psfhosted.org>
In-reply-to
Content
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
History
Date User Action Args
2019-02-02 10:23:57skrahsetrecipients: + skrah, ncoghlan, pitrou, lgautier, mattip
2019-02-02 10:23:55skrahsetmessageid: <1549103035.72.0.161097989982.issue34778@roundup.psfhosted.org>
2019-02-02 10:23:55skrahlinkissue34778 messages
2019-02-02 10:23:55skrahcreate