Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'win32': 0.03; 'subject:Python': 0.05; 'python': 0.09; 'okay': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'sep': 0.09; 'subclass': 0.09; 'typeerror:': 0.09; 'types:': 0.09; 'operands': 0.16; 'play.': 0.16; 'rationale': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'subject:3.3': 0.16; 'url:py3k': 0.16; 'url:whatsnew': 0.16; 'url:dev': 0.17; 'examples': 0.18; '>>>': 0.18; 'sort': 0.21; 'bit': 0.21; '"",': 0.22; 'logical': 0.22; "i'd": 0.22; 'elements': 0.23; 'pass': 0.25; 'header:User-Agent:1': 0.26; 'skip:m 30': 0.26; '(most': 0.27; 'header:X-Complaints-To:1': 0.28; 'skip:( 20': 0.28; 'equality': 0.29; 'array': 0.29; 'class': 0.29; 'url:python': 0.32; 'file': 0.32; 'from:addr:yahoo.co.uk': 0.32; 'structure': 0.32; 'could': 0.32; 'traceback': 0.33; 'to:addr:python-list': 0.33; 'acceptable': 0.35; 'false': 0.35; 'there': 0.35; 'received:org': 0.36; 'explain': 0.36; 'but': 0.36; 'url:org': 0.36; 'compare': 0.36; 'url:library': 0.36; 'should': 0.36; 'mark': 0.38; 'behind': 0.38; 'nothing': 0.38; 'url:docs': 0.38; 'gives': 0.39; 'to:addr:python.org': 0.39; 'header:Received:5': 0.40; 'provide': 0.62; 'more': 0.63; 'lack': 0.71 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Mark Lawrence Subject: Python 3.3 can't sort memoryviews as they're unorderable Date: Sun, 21 Oct 2012 12:24:32 +0100 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: host-78-147-177-143.as13285.net User-Agent: Mozilla/5.0 (Windows NT 6.0; rv:16.0) Gecko/20121010 Thunderbird/16.0.1 X-Antivirus: avast! (VPS 121021-0, 21/10/2012), Outbound message X-Antivirus-Status: Clean X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 37 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1350818534 news.xs4all.nl 6859 [2001:888:2000:d::a6]:36540 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:31846 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 "", line 1, in 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 "", line 1, in 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? -- Cheers. Mark Lawrence.