Wolfgang Maier added the comment:

> memoryview is converted to bytes because len() for memoryview returns a size 
> of first dimension (a number of items for one-dimension view), not a number 
> of bytes.
> 
>>>> m = memoryview(array.array('I', [1, 2, 3]))
>>>> len(m)
> 3
>>>> len(m.tobytes())
> 12
>>>> len(m.cast('B'))
> 12

Right, I was aware of this. But are you saying that my proposed solution (using 
memoryview.nbytes) is wrong ? If so, then cast is certainly an option and 
should still outperform tobytes.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue23688>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to