[issue39610] memoryview.__len__ should raise an exception for 0d buffers

Stefan Krah report at bugs.python.org
Mon Sep 7 13:17:49 EDT 2020


Stefan Krah <stefan at bytereef.org> added the comment:

memoryview can store anything, but only access and display
the native format. The reason is that conversions in the manner
of the struct module are very expensive.

You can construct all sorts of formats that memoryview cannot
handle:

>>> x = array(1, "c")
>>> x
array(b'1', dtype='|S1')
>>> y = memoryview(x)
>>> 
>>> list(y)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NotImplementedError: memoryview: unsupported format 1s


I don't think that the message is obscure, since all these
facts are documented.

----------
assignee:  -> skrah

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue39610>
_______________________________________


More information about the Python-bugs-list mailing list