Stefan Krah added the comment: PEP-3118 specifies strongly typed multi-dimensional arrays. The existing code in the 3.2 memoryview as well as numerous comments by Travis Oliphant make it clear that these capabilities were intended from the start for memoryview as well.
Perhaps the name "memoryview" is a misnomer, since the boundaries between memoryview and NumPy's ndarray become blurry. In fact, the small implementation of an ndarray in Modules/_testbuffer.c is *also* a memoryview in some sense, since it can grab a buffer from an exporter and expose it in the same manner as memoryview. So what I implemented is certainly not only *my* vision. The PEP essentially describes NumPy arrays with an interchange format to convert between NumPy and PIL arrays. It is perhaps unfortunate that the protocol was named "buffer" protocol, since it is actually an advanced "array" protocol. NumPy arrays don't care about the raw memory. It is always the logical array that matters. For example, Fortran and C arrays have different bit patterns in memory but compare equal, a fact that the 3.2 implementation completely misses. 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. Equal formats of course imply equal itemsize. ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue15573> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com