Current Build Status
|Travis||Appveyor||Read the Docs|
pyFFTW is a pythonic wrapper around FFTW 3, the speedy FFT library. The ultimate aim is to present a unified interface for all the possible transforms that FFTW can perform.
Both the complex DFT and the real DFT are supported, as well as on arbitrary
axes of abitrary shaped and strided arrays, which makes it almost
feature equivalent to standard and real FFT functions of
(indeed, it supports the
clongdouble dtype which
numpy.fft does not).
Wisdom import and export now works fairly reliably.
Operating FFTW in multithreaded mode is supported.
pyFFTW implements the numpy and scipy fft interfaces in order for users to take advantage of the speed of FFTW with minimal code modifications.
Requirements (i.e. what it was designed for)
- Python >= 3.7 (lower versions may work)
- Numpy >= 1.16 (lower versions may work)
- FFTW >= 3.3 (lower versions may work) libraries for single, double, and long double precision in serial and multithreading (pthreads or openMP) versions.
- Cython >= 0.29
(install these as much as possible with your preferred package manager).
In practice, pyFFTW may work with older versions of these dependencies, but it is not tested against them.
Scipy and Dask are only required in order to use their respective interfaces. In practice, older versions may work, but they are not tested against. On SciPy versions prior to 1.4, only the scipy.fftpack interface will be available.
We recommend not building from github, but using the release on the python package index with tools such as pip:
pip install pyfftw
Pre-built binary wheels for 64-bit Python on Linux, Mac OS X and Windows are available on the PyPI page for all supported Python versions. Note that we only support binaries for 64-bit Python. If you need to use 32-bit python for some reason, you will have to build pyFFTW from source.
Note that prior to Python 3.9, the Windows installation defaulted to being 32-bit
even on 64-bit Windows, so if you are having problems installing using pip
(typically with an error message like
ERROR: Failed building wheel for pyfftw)
then please check your Python version.
Installation from PyPI may also work on other systems when the FFTW libraries are available, but other platforms have not been tested.
conda install -c conda-forge pyfftw
Windows development builds are also automatically uploaded to bintray as wheels (which are built against numpy 1.10), from where they can be downloaded and installed with something like::
pip install pyFFTW-0.11.1+3.g898bce5-cp36-cp36m-win_amd64.whl
where the version and the revision hash are set accordingly.
Read on if you do want to build from source...
To build in place:
python setup.py build_ext --inplace
pip install -r requirements.txt -e . -v
That cythonizes the python extension and builds it into a shared library
which is placed in
pyfftw/. The directory can then be treated as a python
After you've run
setup.py with cython available, you then have a
normal C extension in the
Further building does not depend on cython (as long as the .c file remains).
During configuration the available FFTW libraries are detected, so pay attention
to the output when running
setup.py. On certain platforms, for example the
long double precision is not available. pyFFTW still builds fine but will fail
at runtime if asked to perform a transform involving long double precision.
Regarding multithreading, if both posix and openMP FFTW libs are available, the
openMP libs are preferred. This preference can be reversed by defining the
PYFFTW_USE_PTHREADS prior to building. If neither
option is available, pyFFTW works in serial mode only.
Platform specific build info
To build for windows from source, download the fftw dlls for your system and the
header file from here (they're in
a zip file) and place them in the pyfftw directory. The files are
libfftw3f-3.dll. These libs use
pthreads for multithreading. If you're using a version of FFTW other than 3.3,
it may be necessary to copy
The builds on PyPI use mingw for the 32-bit release and the Windows SDK
C++ compiler for the 64-bit release. The scripts should handle this
automatically. If you want to compile for 64-bit Windows, you have to use
the MS Visual C++ compiler. Set up your environment as described
here and then
setup.py with the version of python you wish to target and a suitable
For using the MS Visual C++ compiler, you'll need to create a set of
.lib files as described on the
Install FFTW from homebrew:
brew install fftw
Set temporary environmental variables, such that pyfftw finds fftw::
export DYLD_LIBRARY_PATH=/usr/local/lib export LDFLAGS="-L/usr/local/lib" export CFLAGS="-I/usr/local/include"
Now install pyfftw from pip::
pip install pyfftw
It has been suggested that macports might also work fine. You should then replace the LD environmental variables above with the right ones.
- DYLD - path for libfftw3.dylib etc -
find /usr -name libfftw3.dylib
- LDFLAGS - path for fftw3.h -
find /usr -name fftw3.h
Install FFTW from ports tree or
- math/fftw3 - math/fftw3-float - math/fftw3-long
Please install all of them, if possible.
Contributions are always welcome and valued. The primary restriction on accepting contributions is that they are exhaustively tested. The bulk of pyFFTW has been developed in a test-driven way (i.e. the test to be satisfied is written before the code). I strongly encourage potential contributors to adopt such an approach.
See some of my philosophy on testing in development [here] (https://hgomersall.wordpress.com/2014/10/03/from-test-driven-development-and-specifications). If you want to argue with the philosophy, there is probably a good place to do it.
New contributions should adhere to PEP 8, but this is only weakly enforced (there is loads of legacy stuff that breaks it, and things like a single trailing whitespace is not a big deal).
The best place to start with contributing is by raising an issue detailing the specifics of what you wish to achieve (there should be a clear use-case for any new functionality). I tend to respond pretty quickly and am happy to help where I can with any conceptual issues.
I suggest reading the issues already open in order that you know where things might be heading, or what others are working on.