A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2012-October/122361.html below:

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

[Python-Dev] Fwd: Python 3.3 can't sort memoryviews as they're unorderableMark Lawrence breamoreboy at yahoo.co.uk
Tue Oct 23 02:04:47 CEST 2012
-------- Original Message --------
Subject: Python 3.3 can't sort memoryviews as they're unorderable
Date: Sun, 21 Oct 2012 12:24:32 +0100
From: Mark Lawrence <breamoreboy at yahoo.co.uk>
To: python-list at python.org
Newsgroups: gmane.comp.python.general

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?

Nobody on the main Python ml could answer this so can someone please 
explain the background to how memoryviews work in this instance as I'm 
confused, thanks.

Mark Lawrence.



More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4