Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #31908 > unrolled thread

Re: Python 3.3 can't sort memoryviews as they're unorderable

Started byMark Lawrence <breamoreboy@yahoo.co.uk>
First post2012-10-22 23:58 +0100
Last post2012-10-22 23:58 +0100
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: Python 3.3 can't sort memoryviews as they're unorderable Mark Lawrence <breamoreboy@yahoo.co.uk> - 2012-10-22 23:58 +0100

#31908 — Re: Python 3.3 can't sort memoryviews as they're unorderable

FromMark Lawrence <breamoreboy@yahoo.co.uk>
Date2012-10-22 23:58 +0100
SubjectRe: Python 3.3 can't sort memoryviews as they're unorderable
Message-ID<mailman.2641.1350946550.27098.python-list@python.org>
On 21/10/2012 12:24, Mark Lawrence wrote:
> http://docs.python.org/dev/whatsnew/3.3.html states "memoryview
> comparisons now use the logical structure of the operands and compare
> all array elements by value".  So I'd have thought that you should be
> able to compare them and hence sort them, but this is the state of play.
>
> Python 3.3.0 (v3.3.0:bd8afb90ebf2, Sep 29 2012, 10:55:48) [MSC v.1600 32
> bit (Intel)] on win32
> Type "help", "copyright", "credits" or "license" for more information.
>  >>> memoryview(bytearray(range(5))) == memoryview(bytearray(range(5)))
> True
>  >>> memoryview(bytearray(range(5))) != memoryview(bytearray(range(5)))
> False
>  >>> memoryview(bytearray(range(5))) < memoryview(bytearray(range(5)))
> Traceback (most recent call last):
>    File "<stdin>", line 1, in <module>
> TypeError: unorderable types: memoryview() < memoryview()
>
> Okay then, let's subclass memoryview to provide the functionality.
>
>  >>> class Test(memoryview):
> ...     pass
> ...
> Traceback (most recent call last):
>    File "<stdin>", line 1, in <module>
> TypeError: type 'memoryview' is not an acceptable base type
>
> Oh dear.
> http://docs.python.org/py3k/library/stdtypes.html#typememoryview only
> gives examples of equality comparisons and there was nothing that I
> could see in PEP3118 to explain the rationale behind the lack of other
> comparisons.  What have I missed?
>

Anybody?

-- 
Cheers.

Mark Lawrence.

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web