Hello, I believe there is a bug in how assignment to typed memoryviews is handled in the compiler. I think the following code should be valid code:
cdef double[::1] a = np.arange(10, dtype=np.double) cdef double[::1] b = np.empty(a.size // 2) b[:] = a[::2] However, the Cython compiler complains with: Memoryview 'double[:]' not conformable to memoryview 'double[::1]'. A similar thing happens with memoryview copies: cdef double[::1] a = np.arange(10, dtype=np.double) cdef double[::1] b b = a[::2].copy() In both cases I would expect Cython to copy the non contiguous elements of the source array to the destination array (or to a newly created array in the second case). The copy() method is defined here https://github.com/cython/cython/blob/master/Cython/Utility/MemoryView.pyx#L592 and (while I haven't spent much time analyzing it in detail) it seems to do the right thing. Indeed, if I short-circuit the src_conforms_to_dst() function https://github.com/cython/cython/blob/master/Cython/Compiler/MemoryView.py#L141 the code compiles and runs correctly in both cases. I don't know much about how the Cython compiler works, therefore I don't know where to dig for the source of this problem. Can someone point me in the right direction? Thanks. Cheers, Daniele _______________________________________________ cython-devel mailing list cython-devel@python.org https://mail.python.org/mailman/listinfo/cython-devel