Message239971
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] |
|
Date |
User |
Action |
Args |
2015-04-03 11:37:55 | martin.panter | set | recipients:
+ martin.panter, pitrou, ezio.melotti, r.david.murray, skrah, docs@python, serhiy.storchaka |
2015-04-03 11:37:55 | martin.panter | set | messageid: <1428061075.23.0.897847253217.issue23756@psf.upfronthosting.co.za> |
2015-04-03 11:37:55 | martin.panter | link | issue23756 messages |
2015-04-03 11:37:54 | martin.panter | create | |
|