[Python-ideas] 0-dimensional memoryviews?

Antoine Pitrou solipsis at pitrou.net
Mon Sep 3 18:35:08 CEST 2012


On Mon, 3 Sep 2012 11:21:50 -0400
Alexander Belopolsky
<alexander.belopolsky at gmail.com> wrote:
> Consider this:
> 
> >>> memoryview(b'x').cast('B', ()).tolist()
> 120
> 
> The return value of to list() is an int, not a list.
> 
> I suggest to deprecate memoryview.tolist() and .tobytes() methods
> (soft deprecation - in documentation only) and recommend using list(m)
> and  bytes(m) instead.
> 
> For the multidimensional (and 0-dimensional) views, I suggest adding
> an unpack([depth]) method that would unpack a view into a nested list
> of tuples or subviews.

Is there any point in 0-dimensional views? Wouldn't it be clearer if we
simply mandated a strictly positive number of dimensions?

Regards

Antoine.


-- 
Software development and contracting: http://pro.pitrou.net





More information about the Python-ideas mailing list