[SciPy-user] How to: Pass NumPy arrays to C & use SWIG to generate modules

Lou Pecora lou_boog2000 at yahoo.com
Tue Dec 5 10:22:39 CST 2006

Thanks.  I saw that site in a previous google.  But it
seems to be aimed at Windows.  I am on a Mac.  Rather
than fight that battle now, I will try today to just
generate my own simple C extension test routine.  If I
get that far, then that will probably be the way for
me to go.  I haven't checked out pyrex, though.  I
might look at that when I take a break.

If I get the C extension working, I will post an
announcement about it.  It might help non-gurus like
me get started.

-- Lou Pecora
    Naval Research Lab, Washington, DC

--- Gael Varoquaux <gael.varoquaux at normalesup.org>
> Lou,
> I am not a very advanced python user. I do not
> master writing C
> extentions. I have tried simple things, and had
> success with them because
> they were simple enough for me. In order of
> difficulty this is what I
> did:
> - scipy.weave (great, but won't probably suit your
> purposes, have a look
>   at the wiki page)
> - pyrex (same reamrk than above, though the concept
> is fabulous)
> - passing array to C code with ctypes. I think this
> can suit you. It
>   might not be as versatile or powerful as SWIG, but
> I found it was
>   simple enough for my limited knowledge. I started
> out with simple hello
>   word C functions, and was able to pass numpy
> arrays back and forth
>   between numpy and C thanks to Albert Strasheim's
> wiki page
>   http://scipy.org/Cookbook/Ctypes2
> I cannot help you out with SWIG, as I have decided
> it was to complicated
> for me so far.
> Gaël

Want to start your own business?
Learn how on Yahoo! Small Business.

More information about the SciPy-user mailing list