Martin Panter added the comment: 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] ---------- Added file: http://bugs.python.org/file38815/c-contig.v2.patch _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue23756> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com