[SciPy-dev] Does it worth the trouble to support non contiguous array in C extensions ?

Robert Cimrman cimrman3 at ntc.zcu.cz
Tue Nov 28 03:39:55 CST 2006

David Cournapeau wrote:
>     I am about to push in SVN the first version of a small package to 
> compute lpc coefficients and lpc residual. I spent most of the time 
> trying to understand how to handle non contiguous arrays in various 
> parts of the C code...
>     Now, I am wondering: does it really worth the trouble ? I noticed 
> that most of the time, it is even faster (and obviously much easier to 
> code/debug/test, and much more reliable) to just copy the data in a 
> contiguous new array before processing with a C function expecting 
> contiguous array...
>     Is there a general policy regarding thoses issues for scipy ? Is it 
> enough to write simple C extensions expecting contiguous arrays, and 
> converting input to contiguous layout if necessary ?

Well, I do it the simple way - you usually loose more time figuring out 
the c-code for general arrays then ensuring contiguous arrays in Python.
Premature optimization is bad, so unless your code consumes too much 
memory or is too slow (in reality), there is no need to wrestle with 
complex C extensions.

just my 2 cents and imho,
ps: not sure if there is a general policy - people's cases do differ.

More information about the Scipy-dev mailing list