Buffers/ndarrays declared with mode="c" or mode="fortran" will only accept C or Fortran contiguous buffers. But the generated C code does not assume more than contiguity in the fastest varying dimension.
With a = np.zeros((10,10)) b = a[::2, :] the code generated for np.ndarray[double, ndim=2, mode="c"] would work for both a and b. That is, >>> import numpy as np >>> np.zeros((10,10))[:,:].strides (80, 8) >>> np.zeros((10,10))[::2,:].strides (160, 8) But: >>> np.zeros((10,10))[::2,:].flags C_CONTIGUOUS : False <<<<< Not C contiguous!!! F_CONTIGUOUS : False OWNDATA : False WRITEABLE : True ALIGNED : True UPDATEIFCOPY : False Should the run-time type-check instead just check for the stride of the fastest varying dimension? I.e. just assert that b.strides[1] == sizeof(double)? S.M. _______________________________________________ Cython-dev mailing list [email protected] http://codespeak.net/mailman/listinfo/cython-dev
