pyFFTW coming together

It has been sometime since I posted about pyFFTW, the last being well over a year ago when I introduced the wisdom functionality. Despite that, the development has been plodding along steadily (and quiet releases made!) and with the 0.9.1 release it has now reached the stage where it satisfies much of my wishlist.

Please go and check out the latest docs for all the features (the tutorial gives a pretty good overview). The main big improvements since the last post are the pretty neat interfaces module, which offers a drop in replacement for both numpy.fft and scipy.fftpack. Though not all of the functionality of those modules is provided by code within pyFFTW, the namespace is complete through importing parts of numpy.fft or scipy.fftpack as appropriate. There is some slowdown with using pyfftw.interfaces, but this can be largely alleviated with the cache functionality.

Both the above interfaces depend build on the simplified interface to construct FFT objects,, which is itself of potential interest to end users who want to squeeze out every drop of performance without getting bogged down in the details of creating pyfftw.FFTW objects directly.

In addition, some nice helper functionality has been added to pyfftw.FFTW objects. Mainly, the objects can now be called to yield the suitable output, updating the arrays as desired, with normalisation optionally applied to inverse FFTs. This makes creating and calling a pyfftw.FFTW object as simple as:

>>> import pyfftw
>>> a = pyfftw.n_byte_align_empty(4, 32, dtype='complex128')
>>> fft =
>>> a[:] = [1, 2, 3, 4]
>>> fft() # returns the output
array([ 10.+0.j,  -2.+2.j,  -2.+0.j,  -2.-2.j])
>>> fft([5, 6, 7, 8])
array([ 26.+0.j,  -2.+2.j,  -2.+0.j,  -2.-2.j])

Though in the above example, a is set to be aligned to 32 bytes, the builder will by default handle that automatically and the FFTW object will consequently align all the array updates to make sure the alignment is maintained (the optimum alignment is inspected from the CPU). In the above example, the update to the array is not explicitly aligned and is of the incorrect dtype for the FFTW object. The correction is automatically handled by the call.

That is in a nutshell most of important improvements, though there are loads of little usability enhancements and bug fixes. Please, everyone, go and have a play with it and report back bugs to the github page.


About Henry Gomersall

I'm a engineer wanting to make things actually useful. I'm someone that wants to drive technology and ideas to be helpful for everyone. I'm someone that realises the disconnect between technology and utility and I hope to correct that...
This entry was posted in Programming. Bookmark the permalink.

8 Responses to pyFFTW coming together

  1. hi Gomersall, i somehow read your answer about “Does Python go well with QML (Qt-Quick)?”, it seems that you are very good at python/qt things, since i can’t find your email address, i have to ask you a question here: every time i use QQuickView and its setSource() method, it will eat a lot of my memory, what’s worse, hide() and show() method seems to have the same effect, what can i do to release the source QQuickView held and do some cleanup?

    thanks in advance 🙂

  2. Simon says:

    I am trying installing pyfftw on my debian machine to run under python 2.7. I have now successfully installed the library libfftw3-3.3.2-3.1, but I still run into the following error while installing pyfft using either pip or easy_install.

    /tmp/pip_build_root/pyfftw/pyfftw/pyfftw.c:260:19: fatal error: fftw3.h: No such file or directory

    compilation terminated.

    error: command ‘gcc’ failed with exit status 1

    Would you have any idea how to overcome this issue? Thanks

  3. arne says:

    Hello Henry!

    I use pyFFTW in a Google Compute engine and tried to increase the speed of my algorithm by choosing an instance with 32 VCPUs. However, when I change the number of threads nothing happens in terms of speed. When I change this parameter on my local PC I can see an effect.

    Do you have experience in using pyFFTW in google compute engines?

    Thanks for your great wrapper.


    • Hi Arne – non at all I’m afraid. I don’t know what the Google Compute architecture looks like 😦

      It might be that you can slice your problem manually and do it that way – though you might still encounter cache issues *shrug*.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s