Carlo Hamalainen

Passing a NumPy array to a C function


Just a note to myself: has a nice self-contained example of passing a NumPy array to C. And some comments about being aware of non-contiguous arrays or Fortran indexing.

I used this example at work recently to optimize a nested inner for-loop in a statistical bootstrap program and the Python/Cython/C version runs 15 times faster than the plain Python code. The GNU Scientific Library has some convenient random number generators.