[Python-ideas] Memoryview tolist() method is misleading
stefan at bytereef.org
Fri Sep 14 22:00:09 CEST 2012
Alexander Belopolsky wrote:
> Consider this:
> >>> memoryview(b'x').cast('B', ()).tolist()
> 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')
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.
More information about the Python-ideas