[Numpy-discussion] [EXTERNAL] creating/working NumPy-ndarrays in C++

Bill Spotz wfspotz at sandia.gov
Tue Apr 3 15:55:13 EDT 2012


Holger,

SWIG can read C or C++ header files and use them to generate wrapper interfaces for a long list of scripting languages.  It sounds to me like you want to go the other direction -- i.e. you have a code prototyped in python and you want to convert core kernels to C++, perhaps to improve efficiency?  Do I have that right?  If so, then SWIG is not your tool.

If efficiency is what you are after, then Cython could work really well.  You would start with your existing python code and rename appropriate files to become first draft Cython code -- it should compile right out of the box.  You could then start adding efficiencies (typed method arguments, for example).  The end result would be Cython, though, not C++.

If C++ is a requirement, it sounds like Jim's numpy extension to boost.python might be your best bet.  My biggest issue with boost is the heavy templating resulting in nearly indecipherable compiler error messages.

-Bill

On Apr 3, 2012, at 7:06 AM, Holger Herrlich wrote:

> 
> Hi, I plan to migrate core classes of an application from Python to C++
> using SWIG, while still the user interface being Python. I also plan to
> further use NumPy's ndarrays.
> 
> The application's core classes will create the ndarrays and make
> calculations. The user interface (Python) finally receives it. C++ OOP
> features will be deployed.
> 
> What general ways to work with NumPy ndarrays in C++ are here? I know of
> boost.python so far.
> 
> Regards Holger
> 
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion at scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion

** Bill Spotz                                              **
** Sandia National Laboratories  Voice: (505)845-0170      **
** P.O. Box 5800                 Fax:   (505)284-0154      **
** Albuquerque, NM 87185-0370    Email: wfspotz at sandia.gov **





More information about the NumPy-Discussion mailing list