[Python-talk] SWIG tips? Howto?
Christopher Schmidt
crschmidt at crschmidt.net
Tue Aug 18 15:42:47 EDT 2009
On Tue, Aug 18, 2009 at 03:07:00PM -0400, bruce.labitt at autoliv.com wrote:
> Made some progress with my optimizer. Haven't gotten to optimization yet,
> but I have built a function using generators that calculates power. It
> runs a little slow for my liking, it takes about 10 minutes to determine
> the power. This is primarily due to the fft routine. I have to compute a
> ~5M point double precision complex FFT 40 times.
>
> (This is very cool that one can make a five line program using generators
> that does all this work.)
>
> I have used FFTW before (www.fftw.org) for my work. How hard would it be
> to use SWIG to wrap a few FFTW routines to hopefully speed up the FFTs?
I would highly recommend using ctypes for this, instead of SWIG. SWIG is
fine when you are the library maintainer looking to provide the library
to multiple languages, but for Python binding to existing library,
ctypes is useful.
I know nothing about C/C++ and have successfully turned a C library into a
Python library for some simple tasks, simply via copy paste.
Regards,
--
Christopher Schmidt
Web Developer
More information about the Python-talk
mailing list