On Thu, Apr 24, 2008 at 4:57 PM, Zachary Pincus <[EMAIL PROTECTED]> wrote:
> The reason that one must slice before .view()ing to allow arbitrary > alignment is as follows. Imagine that we want rows of four 2-byte > shorts aligned to 3-byte boundaries. (Assume that we already have a > buffer that starts on a 3-byte boundary.) So we need an array that's 9 > bytes wide by however many rows, and then we just want to use the > first eight bytes of row. If we slice first, we can get a strided > array that is eight bytes wide, and thus something that we can > interpret as four shorts. (That is, if .view() could handle strided > arrays.) > > On the other hand, there's absolutely no way that we can .view() > before slicing, because our underlying array is 9 bytes wide, and you > can't look at 9 bytes as any integral number of 2-byte shorts. > So .view() should properly fail, and thus we can't get to the slicing. Yes, you are right, sorry. -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco _______________________________________________ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion