polars-rfft
FFT as native Polars expressions. Built with Rust (RustFFT) and PyO3 for zero-copy, vectorized computation over Polars DataFrames.
Install
pip install polars-rfft
Quick start
import polars as pl
from polars_rfft import rfft
df = pl.DataFrame({"signal": [1.0, 0.0, -1.0, 0.0, 1.0, 0.0, -1.0, 0.0]})
# Forward FFT — returns struct {re, im}
df.with_columns(spectrum=rfft(pl.col("signal")).fft())
Roundtrip: FFT → IFFT
df.with_columns(
recovered=rfft(rfft(pl.col("signal")).fft()).ifft_real()
)
Magnitude, phase, power spectrum
fft_expr = rfft(pl.col("signal")).fft()
df.with_columns(
mag=rfft(fft_expr).magnitude(),
phase=rfft(fft_expr).phase(),
power=rfft(fft_expr).power_spectrum(),
)
Complex-valued input
df = pl.DataFrame({
"z": [{"re": 1.0, "im": 0.0}, {"re": 0.0, "im": 1.0},
{"re": -1.0, "im": 0.0}, {"re": 0.0, "im": -1.0}]
})
df.with_columns(spectrum=rfft(pl.col("z")).fft_complex())
API reference
Complex values are represented as struct columns with fields re (real) and im (imaginary).
| Method | Input | Output | Description |
|---|---|---|---|
fft() |
f64 | struct{re,im} | Forward FFT on real signal |
fft_complex() |
struct{re,im} | struct{re,im} | Forward FFT on complex signal |
ifft() |
struct{re,im} | struct{re,im} | Inverse FFT (normalized by 1/N) |
ifft_real() |
struct{re,im} | f64 | Inverse FFT, real part only |
magnitude() |
struct{re,im} | f64 | |
phase() |
struct{re,im} | f64 | atan2(im, re) in radians |
power_spectrum() |
struct{re,im} | f64 |
All methods are accessed via the rfft() wrapper:
from polars_rfft import rfft
rfft(pl.col("signal")).fft() # forward
rfft(pl.col("spectrum")).ifft() # inverse
rfft(pl.col("spectrum")).magnitude() # magnitude
Direct functions
For lower overhead on smaller signals, fft_direct and ifft_direct bypass the Polars expression engine and operate directly on Series:
from polars_rfft import fft_direct, ifft_direct
re, im = fft_direct(df["signal"]) # Series → (Series, Series)
re, im = ifft_direct(re, im) # (Series, Series) → (Series, Series)
Performance
Benchmarked end-to-end against numpy on signals of varying length. Median of 7 runs after warmup.
Expression API (rfft().fft())
| Signal length | Operation | polars-rfft | numpy | Speedup |
|---|---|---|---|---|
| 1,024 | fft | 0.14 ms | 0.02 ms | 0.2x |
| 4,096 | fft | 0.24 ms | 0.08 ms | 0.3x |
| 16,384 | fft | 0.66 ms | 0.99 ms | 1.5x |
| 65,536 | fft | 2.2 ms | 4.7 ms | 2.1x |
| 262,144 | fft | 10.2 ms | 22.1 ms | 2.2x |
| 1,048,576 | fft | 33.9 ms | 53.3 ms | 1.9x |
Direct API (fft_direct())
Bypasses Polars expression dispatch for ~0.1ms less overhead:
| Signal length | Operation | fft_direct | numpy | Speedup |
|---|---|---|---|---|
| 64 | fft | 0.014 ms | 0.013 ms | 0.9x |
| 256 | fft | 0.018 ms | 0.013 ms | 0.7x |
| 1,024 | fft | 0.040 ms | 0.022 ms | 0.6x |
| 4,096 | fft | 0.14 ms | 0.08 ms | 0.5x |
| 16,384 | fft | 0.64 ms | 0.99 ms | 1.5x |
| 65,536 | fft | 2.1 ms | 4.7 ms | 2.3x |
| 262,144 | fft | 9.9 ms | 22.1 ms | 2.2x |
| 1,048,576 | fft | 27.9 ms | 53.3 ms | 1.9x |
At small sizes (< 4K), numpy is faster due to its highly optimized C/Fortran backend. At 16K+ elements, RustFFT's radix algorithms dominate — up to 2.3x faster than numpy. The direct API eliminates ~0.1ms of Polars expression dispatch overhead, matching numpy at very small sizes.
Run it yourself:
pip install numpy
python benchmarks/bench_fft.py --sizes 1024 16384 262144 1048576
License
MIT
Metadata
Release files for polars-rfft 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| polars_rfft-0.1.1.tar.gz | 30.3 kB | With provenance | Details for polars_rfft-0.1.1.tar.gz |
Built distributions (wheels)
Total release size: 26.6 MB
Release files / polars_rfft-0.1.1.tar.gz
| Download URL | polars_rfft-0.1.1.tar.gz |
|---|---|
| Size | 30.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2239cab60cc78ae3c773cc7dfbcf73ebf43e31dff355a187e3f352d4d6aec43e
|
|
BLAKE2b-256 checksum How to use checksums |
13a2b5395bed26a04b0f62e816547b088b1b41fce746558075b43f890ce3995b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
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 Mar 13, 2026.
Transparency logRelease files / polars_rfft-0.1.1-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | polars_rfft-0.1.1-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 4.7 MB |
| Tags | Linux glibc 2.17+ x86-64 PyPy 3.11 PyPy 3.11 7.3 |
|
SHA-256 checksum How to use checksums |
696be55156f8ff1ea93fba6a38087b74601795505521d0f122f12ee24db7835c
|
|
BLAKE2b-256 checksum How to use checksums |
5a61e2e197dd3c62a3557f943ce9c8efae555c95fae53bf623a81e25656e4268
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
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 Mar 13, 2026.
Transparency logRelease files / polars_rfft-0.1.1-cp39-abi3-win_amd64.whl
| Download URL | polars_rfft-0.1.1-cp39-abi3-win_amd64.whl |
|---|---|
| Size | 4.9 MB |
| Tags | CPython 3.9 Windows x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
342e12270cb921dd282e4a5c39b542b1ddfecef171d0deab0ef732402eeda6fa
|
|
BLAKE2b-256 checksum How to use checksums |
02601a18e8b478418e692858302aeed8e71e35790577393ffcb10acfd4f34a91
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
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 Mar 13, 2026.
Transparency logRelease files / polars_rfft-0.1.1-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | polars_rfft-0.1.1-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 4.7 MB |
| Tags | CPython 3.9 Linux glibc 2.17+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
488dc9b18fbe269a9652b7793e197a45946030c13953d6b5fb11d7008d423322
|
|
BLAKE2b-256 checksum How to use checksums |
0c0d442c72797ea001b1618ac9babf0f3530a4084c53595d9f2472bab974a6ab
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
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 Mar 13, 2026.
Transparency logRelease files / polars_rfft-0.1.1-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
| Download URL | polars_rfft-0.1.1-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl |
|---|---|
| Size | 4.2 MB |
| Tags | CPython 3.9 Linux glibc 2.17+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
caac972cc123e05296b844dda69a1adc98b52ed6fa1ada1775167c2ff6e59d68
|
|
BLAKE2b-256 checksum How to use checksums |
e9780ab16ddf5d933ec5b71907b687726d427578e10bf0e63bd52596de218b9f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
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 Mar 13, 2026.
Transparency logRelease files / polars_rfft-0.1.1-cp39-abi3-macosx_11_0_arm64.whl
| Download URL | polars_rfft-0.1.1-cp39-abi3-macosx_11_0_arm64.whl |
|---|---|
| Size | 3.8 MB |
| Tags | CPython 3.9 abi3 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
339fe4c77160c0bf8721192c2168a19eaf510b4d0e783876d0fa093ef99aa9d5
|
|
BLAKE2b-256 checksum How to use checksums |
0b66d2ba5e5da1b5f22232aefc16f0c78232e0bf9cbbc9b08d8c05cadac215dc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
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 Mar 13, 2026.
Transparency logRelease files / polars_rfft-0.1.1-cp39-abi3-macosx_10_12_x86_64.whl
| Download URL | polars_rfft-0.1.1-cp39-abi3-macosx_10_12_x86_64.whl |
|---|---|
| Size | 4.3 MB |
| Tags | CPython 3.9 abi3 macOS 10.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
05eb57b783d89d867cad0e317703cf2a6c8126f377707a38d37cd0a23ac91150
|
|
BLAKE2b-256 checksum How to use checksums |
08e2fafa7511825a2de472a50216506795845fbdda89aab62612a5ebaf50656d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
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 Mar 13, 2026.
Transparency logSecurity for polars-rfft 0.1.1
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.
Attestation for polars_rfft-0.1.1.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 Mar 13, 2026.
Transparency logA 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.