[Numpy-discussion] [EXTERNAL] Re: numpy.i and std::complex

Bill Spotz wfspotz at sandia.gov
Mon Oct 27 12:20:25 EDT 2014


Python is its own language, but it allows you to import C and C++ code, thus creating an interface to these languages.  Just as with SWIG, you would import a module written in Cython that gives you access to underlying C/C++ code.

Cython is very nice for a lot of applications, but it is not the best tool for every job of designing an interface.  SWIG is still preferable if you have a large existing code base to wrap or if you want to support more target languages than just Python.  I have a specific need for cross-language polymorphism, and SWIG is much better at that than Cython is.  It all depends.

Looks like somebody needs to update the c-info.python-as-glue.html page.

-Bill

On Oct 27, 2014, at 10:04 AM, Glen Mabey <gmabey at swri.org> wrote:

> On Oct 27, 2014, at 10:45 AM, Sturla Molden <sturla.molden at gmail.com>
> wrote:
> 
>> Glen Mabey <gmabey at swri.org> wrote:
>> 
>>> I'd really like for this to be included alongside numpy.i -- but maybe I
>>> overestimate the number of numpy users who use complex data (let your
>>> voice be heard!) and who also end up using std::complex in C++ land.
>> 
>> I don't think you do. But perhaps you overestimate the number of NumPy
>> users who use Swig?
> 
> Likely so.
> 
>> Cython seems to be the preferred wrapping tool today, and it understands
>> complex numbers:
>> 
>>   cdef double complex J = 0.0 + 1j
>> 
>> If you tell Cython to emit C++, this will result in code that uses
>> std::complex<double>. 
> 
> I chose swig after reviewing the options listed here, and I didn't see cython on the list:
> 
> http://docs.scipy.org/doc/numpy/user/c-info.python-as-glue.html
> 
> I guess that's because cython is different language, right?  So, if I want to interactively call C++ functions from say ipython, then is cython really an option?
> 
> Thanks for the feedback --
> Glen
> _______________________________________________
> 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