[issue15573] Support unknown formats in memoryview comparisons

Stefan Krah report at bugs.python.org
Fri Aug 10 22:53:42 CEST 2012


Stefan Krah added the comment:

Martin v. Loewis <report at bugs.python.org> wrote:
> Sure: someone would have to make a proposal what exactly that is.
> IMO, the 3.2 definition *was* simple, but apparently it was considered
> too simple.

It was simply broken in multiple ways. Example:

>>> from numpy import *
>>> x = array([1,2,3,4,5], dtype='B')
>>> y = array([5,4,3,2,1], dtype='B')
>>> z = y[::-1]
>>> 
>>> x == z
array([ True,  True,  True,  True,  True], dtype=bool)
>>> memoryview(x) == memoryview(z)
False
Segmentation fault


I'm not even talking about the segfault here. Note that x == z, but
memoryview(x) != memoryview(z), because the logical structure is
not taken into account.

Likewise, one could construct cases where one array contains a float
NaN and the other an integer that happens to have the same bit pattern.

The arrays would not be equal, but their memoryviews would be equal.



> So either Stefan gets to define his view of equality, or
> somebody else needs to make a (specific) counter-proposal.

The view is defined by the PEP that clearly models NumPy. I'm curious what
counter-proposal will work with NumPy and PIL.

----------

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


More information about the Python-bugs-list mailing list