Memoryview tolist() method is misleading
![](https://secure.gravatar.com/avatar/4ebd537df10ab19b4c524299026d936e.jpg?s=120&d=mm&r=g)
Sept. 14, 2012
4 p.m.
Alexander Belopolsky wrote:
Consider this:
memoryview(b'x').cast('B', ()).tolist() 120
The return value of to list() is an int, not a list.
That's because NumPy's tolist() does the same thing:
x = numpy.array(120, dtype='B') x array(120, dtype=uint8) x.tolist() 120
If you implement tolist() recursively like in _testbuffer.c and choose the zeroth dimension as the base case, you arrive at single elements. So at least it's not completely unnatural. Stefan Krah
4535
Age (days ago)
4535
Last active (days ago)
0 comments
1 participants
participants (1)
-
Stefan Krah