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

Gael Varoquaux gael.varoquaux at normalesup.org
Fri Dec 1 09:14:30 CST 2006


Did you consider using ctypes. http://scipy.org/Cookbook/Ctypes2 . I had
a great experience with it.

Gaël

On Fri, Dec 01, 2006 at 07:06:57AM -0800, Lou Pecora wrote:
> I have some number crunching routines I want to code
> in C or C++ and then use SWIG to create a module I can
> import.  I can get the simple example.i stuff in the
> SWIG package to work, but I need to pass NumPy arrays
> back and forth.  I have looked up typemaps and googled
> examples, but whatever I find is pretty general and
> high level for me and my needs -- at least until I get
> more experience.

> Does anyone know of simple examples of passing NumPy
> arrays and using SWIG?  I really don't want to branch
> out to other objects, yet. No C++ templates or fancy
> stuff.  Just NumPy arrays to C arrays (or something
> reasonable in C) will get me a long way in my coding
> for now.

> Thanks for any suggestions or pointers.

> -- Lou Pecora
>    US Naval Research Lab



> ____________________________________________________________________________________
> Do you Yahoo!?
> Everyone is raving about the all-new Yahoo! Mail beta.
> http://new.mail.yahoo.com
> _______________________________________________
> SciPy-user mailing list
> SciPy-user at scipy.org
> http://projects.scipy.org/mailman/listinfo/scipy-user


More information about the SciPy-user mailing list