Author skrah
Recipients Arfrever, christian.heimes, georg.brandl, loewis, mark.dickinson, meador.inge, ncoghlan, pitrou, python-dev, skrah, vstinner
Date 2012-08-10.20:05:48
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <20120810200549.GA23186@sleipnir.bytereef.org>
In-reply-to <50255E72.4050803@v.loewis.de>
Content
The ideal specification is:

1) Arrays v and w are equal iff format and shape are equal and for all valid
   indices allowed by shape

     memcmp((char *)PyBuffer_GetPointer(v, indices),
            (char *)PyBuffer_GetPointer(w, indices),
            itemsize) == 0.

2) Two format strings s and t are equal if canonical(s) == canonical(t).

End ideal specification.

Purely to *facilitate* the implementation of a format comparison function,
I suggested:

3) An exporter must initialize the format field of a Py_buffer structure
   with canonical(s).

If *all* exporters obey 3), a format comparison function can simply
call strcmp(s, t) (after sorting out the byte order specifier).

Specifically, if x and y are equal, then:

  a) x == memoryview(x) == memoryview(y) == y

If x and y are equal and exporter x does *not* obey 3), but exporter y does,
then:

  b) x == memoryview(x) != memoryview(y) == y

Under rule 3) this would be the fault of exporter x.

For Python 3.3 it is also possible to state only 1) and 2), with a caveat in
the documentation that case b) might occur until the format comparison function
in memoryview implements the reductions to canonical forms.

The problem is that reductions to canonical forms might get very complicated
if #3132 is implemented.
History
Date User Action Args
2012-08-10 20:05:49skrahsetrecipients: + skrah, loewis, georg.brandl, mark.dickinson, ncoghlan, pitrou, vstinner, christian.heimes, Arfrever, meador.inge, python-dev
2012-08-10 20:05:48skrahlinkissue15573 messages
2012-08-10 20:05:48skrahcreate