[issue15573] Support unknown formats in memoryview comparisons

Stefan Krah report at bugs.python.org
Fri Aug 10 09:48:39 CEST 2012


Stefan Krah added the comment:

> I can easily provide a specification that makes the current implementation "correct"

Yes, the current specification is: memoryview only attempts to
compare arrays with known (single character native) formats and
returns "not equal" otherwise.

The problem is that for backwards compatibility memoryview accepts
arrays with arbitrary format strings. In operations like tolist()
it's possible to raise NotImplemented, but for equality comparisons
that's not possible.


Note that in 3.2 memoryview would return "equal" for arrays that
simply aren't equal, if those arrays happen to have the same bit
pattern.


One way to deal with this is to demand a strict canonical form
of format strings for PEP-3118, see msg167687.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue15573>
_______________________________________


More information about the Python-bugs-list mailing list