Skip to main content

Rocket-FFT

PyPI version License python status downloads

Rocket-FFT makes Numba aware of numpy.fft and scipy.fft. It takes its name from the PocketFFT library that originally powered it, and Numba's goal of making your scientific Python code blazingly fast - like a rocket. Today, Rocket-FFT is powered by PocketFFT's successor DUCC0, the same library that runs scipy.fft.

Getting Started

The easiest way to get Rocket-FFT is to:

$ pip install rocket-fft

Alternatively, you can build it from source:

$ git clone https://github.com/styfenschaer/rocket-fft.git
$ cd rocket-fft
$ pip install .

The latter requires a C++17 compiler. Rocket-FFT requires Python 3.10 or newer, Numba 0.60 or newer and NumPy 2.0 or newer. SciPy is optional.

Once installed successfully, the following will work (no import required):

import numba as nb
import numpy as np

@nb.njit
def jit_fft(x):
    return np.fft.fft(x)

a = np.array([1, 6, 1, 8, 0, 3, 3, 9])
jit_fft(a)

Supported Functions

Rocket-FFT supports all functions of numpy.fft and scipy.fft in jitted code, with all their arguments. The results match NumPy and SciPy, down to the data type and the memory layout of the returned arrays. The exceptions are:

  • SciPy's backend functions (set_backend, skip_backend, set_global_backend and register_backend) and its set_workers and get_workers. Use the workers argument or Rocket-FFT's own set_workers (see below) instead.
  • The plan argument must be None, xp must be None or NumPy, and device must be None or "cpu".
  • An empty axes tuple is not allowed.
  • Half precision (float16) and extended precision (longdouble) are not supported.

Rocket-FFT also extends Numba's numpy.roll to NumPy's full signature roll(a, shift, axis=None), and provides loggamma and poch (as in scipy.special) in rocket_fft.special. These are ufuncs that work in pure Python and in jitted code.

Performance Tips

Compiling a call takes well below 200 milliseconds, whichever arguments you pass. Compiled functions can be cached with @nb.njit(cache=True).

Multidimensional transforms can use several threads. Pass workers to the scipy.fft functions, or set the default for all transforms with set_workers, which also affects functions that were compiled before:

import rocket_fft

rocket_fft.set_workers(4)
rocket_fft.get_workers()  # 4

FFTs are fastest for lengths with small prime factors. scipy.fft.next_fast_len and scipy.fft.prev_fast_len find such lengths, also in jitted code:

import scipy.fft

@nb.njit
def padded_fft(x):
    n = scipy.fft.next_fast_len(x.size)
    return np.fft.fft(x, n)

If SciPy is not installed, use rocket_fft.next_fast_len and rocket_fft.prev_fast_len instead. They work the same way.

On x86-64, Rocket-FFT contains two builds of its native library and picks the faster one your CPU supports: one that uses AVX2 instructions, and a generic one. You can force one of them by setting the environment variable ROCKET_FFT_SIMD to generic or avx2. This must happen before Rocket-FFT is imported or any function using it is compiled:

import os
os.environ["ROCKET_FFT_SIMD"] = "generic"

NumPy and SciPy Semantics

NumPy and SciPy show a subtle difference in how they handle the axes argument: NumPy allows duplicate axes in its multidimensional transforms (as in fftn(x, axes=(0, 0))), whereas SciPy doesn't. Rocket-FFT follows each library: calls to numpy.fft behave like NumPy, calls to scipy.fft like SciPy.

Low-Level Interface

Rocket-FFT also provides a low-level interface to DUCC0. It has the least overhead, gives the most flexibility, and includes transforms that are not available through numpy.fft and scipy.fft. Its functions can only be called from jitted code. You can import them from the rocket_fft namespace:

from rocket_fft import c2c, dct, ...

The low-level interface includes the following functions:

def c2c(ain: NDArray[c8] | NDArray[c16], aout: NDArray[c8] | NDArray[c16], axes: NDArray[i8], forward: bool, fct: float, nthreads: int) -> None: ...
def r2c(ain: NDArray[f4] | NDArray[f8], aout: NDArray[c8] | NDArray[c16], axes: NDArray[i8], forward: bool, fct: float, nthreads: int) -> None: ...
def c2r(ain: NDArray[c8] | NDArray[c16], aout: NDArray[f4] | NDArray[f8], axes: NDArray[i8], forward: bool, fct: float, nthreads: int) -> None: ...
def c2c_sym(ain: NDArray[f4] | NDArray[f8], aout: NDArray[c8] | NDArray[c16], axes: NDArray[i8], forward: bool, fct: float, nthreads: int) -> None: ...
def dct(ain: NDArray[f4] | NDArray[f8], aout: NDArray[f4] | NDArray[f8], axes: NDArray[i8], type: int, fct: float, ortho: bool, nthreads: int) -> None: ...
def dst(ain: NDArray[f4] | NDArray[f8], aout: NDArray[f4] | NDArray[f8], axes: NDArray[i8], type: int, fct: float, ortho: bool, nthreads: int) -> None: ...
def r2r_separable_hartley(ain: NDArray[f4] | NDArray[f8], aout: NDArray[f4] | NDArray[f8], axes: NDArray[i8], fct: float, nthreads: int) -> None: ...
def r2r_genuine_hartley(ain: NDArray[f4] | NDArray[f8], aout: NDArray[f4] | NDArray[f8], axes: NDArray[i8], fct: float, nthreads: int) -> None: ...
def r2r_fftpack(ain: NDArray[f4] | NDArray[f8], aout: NDArray[f4] | NDArray[f8], axes: NDArray[i8], real2hermitian: bool, forward: bool, fct: float, nthreads: int) -> None: ...
def good_size(target: int, real: bool = False) -> int: ...
def prev_good_size(target: int, real: bool = False) -> int: ...

The functions write their result into aout, whose shape determines the transform lengths: where ain and aout differ in size along an axis, the input is zero-padded or truncated. The scale factor fct is applied as is, without any normalization. For example:

from rocket_fft import c2c

@nb.njit
def unnormalized_fft(x):
    out = np.empty_like(x)
    c2c(x, out, np.array([0]), True, 1.0, 1)
    return out

Note that the low-level interface provides less safety and convenience than numpy.fft and scipy.fft. You may want to consult the DUCC0 documentation before using it.

Contributing

Contributions are welcome. CONTRIBUTING.md explains how to set up a development environment, run the tests and benchmarks, and release; ARCHITECTURE.md explains how Rocket-FFT works internally.

License

Rocket-FFT is distributed under the BSD-3-Clause License. The bundled DUCC0 sources are dual-licensed under BSD-3-Clause or GPL-2.0-or-later and are used under the BSD-3-Clause terms.

Metadata

Release files for rocket-fft 0.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for rocket-fft 0.4.0
File Size Uploaded Provenance Actions
rocket_fft-0.4.0.tar.gz 141.9 kB With provenance Details for rocket_fft-0.4.0.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for rocket-fft 0.4.0
File Actions
rocket_fft-0.4.0-cp310-abi3-win_arm64.whl CPython 3.10 abi3 Windows ARM64 Details for rocket_fft-0.4.0-cp310-abi3-win_arm64.whl
rocket_fft-0.4.0-cp310-abi3-win_amd64.whl CPython 3.10 abi3 Windows x86-64 Details for rocket_fft-0.4.0-cp310-abi3-win_amd64.whl
rocket_fft-0.4.0-cp310-abi3-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl CPython 3.10 abi3 Linux glibc 2.27+ x86-64, Linux glibc 2.28+ x86-64 Details for rocket_fft-0.4.0-cp310-abi3-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
rocket_fft-0.4.0-cp310-abi3-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl CPython 3.10 abi3 Linux glibc 2.28+ ARM64, Linux glibc 2.26+ ARM64 Details for rocket_fft-0.4.0-cp310-abi3-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl
rocket_fft-0.4.0-cp310-abi3-macosx_11_0_arm64.whl CPython 3.10 abi3 macOS 11.0+ ARM64 Details for rocket_fft-0.4.0-cp310-abi3-macosx_11_0_arm64.whl
rocket_fft-0.4.0-cp310-abi3-macosx_10_15_x86_64.whl CPython 3.10 abi3 macOS 10.15+ x86-64 Details for rocket_fft-0.4.0-cp310-abi3-macosx_10_15_x86_64.whl

Total release size: 5.5 MB

Release files / rocket_fft-0.4.0.tar.gz

Download URL rocket_fft-0.4.0.tar.gz
Size 141.9 kB
Tags Source
SHA-256 checksum
How to use checksums
d4c4003661507dedb5fc1a2036fdb40d6af95b523bfdf745f39ca4c34fb69761
BLAKE2b-256 checksum
How to use checksums
da868f209fd19227b35848032aa2fc00a013e250a2ecae554ad4c37cc6fe7f0d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 16, 2026.

Transparency log

Release files / rocket_fft-0.4.0-cp310-abi3-win_arm64.whl

Download URL rocket_fft-0.4.0-cp310-abi3-win_arm64.whl
Size 610.7 kB
Tags CPython 3.10 Windows ARM64 abi3
SHA-256 checksum
How to use checksums
fc08e61c3d1c064792f09824f15304eabd177f404496f1291b9eac64cd79f0e4
BLAKE2b-256 checksum
How to use checksums
5f4ac63e206e8dfd2505005c00e40224cdd4a4071a3b01b9671b039f155d86ac
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 16, 2026.

Transparency log

Release files / rocket_fft-0.4.0-cp310-abi3-win_amd64.whl

Download URL rocket_fft-0.4.0-cp310-abi3-win_amd64.whl
Size 715.8 kB
Tags CPython 3.10 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
74aee5b9083745f68674aa66a38b4b05683f9a0a6bda92d0ff6b6ac70e489f9d
BLAKE2b-256 checksum
How to use checksums
0454dfecd043b6df7514a1f12ed9f61306189d03e1d8ab89555956abba52b9f2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 16, 2026.

Transparency log

Release files / rocket_fft-0.4.0-cp310-abi3-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL rocket_fft-0.4.0-cp310-abi3-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Size 1.6 MB
Tags CPython 3.10 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64 abi3
SHA-256 checksum
How to use checksums
a00072f76cec10faa74a81aaefff973c79949402c6c44ed3ee84f4e90fd69b9c
BLAKE2b-256 checksum
How to use checksums
a17364abe222809b0ad561ed3021fe0b0bcb3a1c22f6a9adc1f4d437594868db
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 16, 2026.

Transparency log

Release files / rocket_fft-0.4.0-cp310-abi3-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl

Download URL rocket_fft-0.4.0-cp310-abi3-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl
Size 692.4 kB
Tags CPython 3.10 Linux glibc 2.26+ ARM64 Linux glibc 2.28+ ARM64 abi3
SHA-256 checksum
How to use checksums
68bf4ff76949b970898c1d9ea5b949061876185f5d8c4a3f283123bc72a5eda5
BLAKE2b-256 checksum
How to use checksums
a7e865e0c83e6bbf0abc1530980679fd34237e44c0a6ec19fb1caff42fdeb783
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 16, 2026.

Transparency log

Release files / rocket_fft-0.4.0-cp310-abi3-macosx_11_0_arm64.whl

Download URL rocket_fft-0.4.0-cp310-abi3-macosx_11_0_arm64.whl
Size 498.7 kB
Tags CPython 3.10 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
72d1a0ce6e5e520cecdd8aa2e406a958781a83f0dd0c5e27ca4bb2fb44bbddf0
BLAKE2b-256 checksum
How to use checksums
b93a238ace3fc75076c450e6fb41aea1df94ac5567ab7f57f1c5d34d25ceee4f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 16, 2026.

Transparency log

Release files / rocket_fft-0.4.0-cp310-abi3-macosx_10_15_x86_64.whl

Download URL rocket_fft-0.4.0-cp310-abi3-macosx_10_15_x86_64.whl
Size 1.2 MB
Tags CPython 3.10 abi3 macOS 10.15+ x86-64
SHA-256 checksum
How to use checksums
34ecca4ccfeecbe0bb9702c93a2167d4830743cb1484a00884093c4b35df08a3
BLAKE2b-256 checksum
How to use checksums
7dcaee22d192661fa98e4ef390598acc8f7129b6e270f312ebb5f378cfd53538
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 16, 2026.

Transparency log

Security for rocket-fft 0.4.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 7 files in this release have been uploaded with provenance metadata.

Select from 7 files

Attestation for rocket_fft-0.4.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 16, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page