Francesc Altet wrote:
I'm a bit lost with the next example:
In : from numarray import * In : a=arange(10) In : a.iscontiguous() Out: 1 In : b=a[::2] In : b.iscontiguous() Out: 0
That seems to suggest that b shares the same data buffer than a. Indeed:
In : a._data Out: <memory at 0x082494d8 with size:0x00000028 held by object 0xb762c260 aliasing object 0x00000000> In : b._data Out: <memory at 0x082494d8 with size:0x00000028 held by object 0xb762c260 aliasing object 0x00000000>
OK so far.
At this point, I believe that _bytestride should be different on both arrays, but:
In : a._bytestride Out: 4 In : b._bytestride Out: 4
while I expected to find b._bytestride equal to 8.
Is that an error or a lack of understanding on my part?
What you are looking for is _strides. Since, in general, arrays can be multidimensional, the stride(s) need to be specified as a sequence. _bytestride appears to be equivalent to itemsize(); that is, it tells how many bytes are required to represent one item of the array. Here's what strides looks like in your case:
Hope that helps,