Author martin.panter
Recipients docs@python, ezio.melotti, martin.panter, pitrou, r.david.murray, serhiy.storchaka, skrah
Date 2015-04-03.11:37:54
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1428061075.23.0.897847253217.issue23756@psf.upfronthosting.co.za>
In-reply-to
Content
I’m sorry Stefan, I now realize my changes for len(view) were indeed wrong, and the original was much more correct. I still think the tobytes() and maybe tolist() documentation could be improved, but that is a separate issue to the bytes-like definition.

I am posting c-contig.v2.patch. Hopefully you will find it is truer to my original scope :)

* Removed changes to stdtypes.rst
* Scaled back changes in buffer.rst to only explain “C-contiguous”
* Tweaked glossary definition. Not all memoryview() objects are applicable.

David: The result of passing a Fortran array directly in a bytes-like context is typically BufferError. If this were relaxed, then we would get the inconsistency with tobytes().

>>> import _testbuffer, sys
>>> layout = [11, 21, 12, 22]
>>> fortran_array = _testbuffer.ndarray(layout, format="B", flags=0, shape=[2, 2], strides=[1, 2], offset=0)
>>> sys.stdout.buffer.write(fortran_array)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
BufferError: ndarray is not C-contiguous
>>> list(memoryview(fortran_array).tobytes())  # C-contiguous order!
[11, 12, 21, 22]
History
Date User Action Args
2015-04-03 11:37:55martin.pantersetrecipients: + martin.panter, pitrou, ezio.melotti, r.david.murray, skrah, docs@python, serhiy.storchaka
2015-04-03 11:37:55martin.pantersetmessageid: <1428061075.23.0.897847253217.issue23756@psf.upfronthosting.co.za>
2015-04-03 11:37:55martin.panterlinkissue23756 messages
2015-04-03 11:37:54martin.pantercreate