Message 167946 - Python tracker (original) (raw)
Stefan's proposed definition is correct. Shapes define array types, format strings define entry types, then the actual memory contents define the value.
It's not "Stefan's definition of equivalence", it's what a statically typed array means.
The 3.2 way is completely broken, as it considers arrays containing completely different data as equal if the memory layout happens to be the same by coincidence.
3.3 is currently also broken, as it considers arrays that do contain the same values to be different.
Stefan's patch fixes that by checking the shape and format first, and then checking the value. It's exactly the same as doing an instance check in an eq method.
The requirement for a canonical format is for sanity's sake: the general equivalence classes are too hard to figure out.