High-performance Excel and CSV file generation for Python, powered by Rust. ~7x-9x faster than XlsxWriter, ~5x faster CSV (records) than Python's csv module, and ~12x faster Pandas DataFrame → CSV than pandas.to_csv via zero-copy Arrow. On free-threaded Python the gap widens to ~12x, because it parallelises better than a pure-Python writer can — see Concurrency.
from rustpy_xlsxwriter import FastExcel
FastExcel("report.xlsx").sheet("Sheet1", records).save()
Every row above is single-threaded, and the GIL keeps it that way. On
free-threaded Python both writers spread across threads — but RustPy spreads
further, so the speedup against xlsxwriter grows from 7.9x to 12.1x at
eight threads. Full numbers in Concurrency.
† DataFrame → CSV rows measured on a separate machine — only speedup ratio shown. The Pandas path goes through zero-copy Arrow C Data Interface.
Concurrency
Every row below writes the same 1,000,000 records — the Records row from the
table above — just spread over more workers. xlsxwriter is measured at each
worker count too. Reproduce with python benchmark.py --concurrent under each
interpreter:
Python 3.14 — standard build
Workers
RustPy
xlsxwriter
Speedup
1
8.88s
65.40s
7.4x
2
6.56s
72.79s
11.1x
4
5.79s
168.62s
29.1x
8
5.26s
159.41s
30.3x
Python 3.14t — free-threaded
Workers
RustPy
xlsxwriter
Speedup
1
9.00s
71.54s
7.9x
2
4.61s
43.07s
9.3x
4
2.63s
27.67s
10.5x
8
1.63s
19.72s
12.1x
With the GIL, RustPy still spreads. It goes from 8.88s to 5.26s, a 1.7x
gain, because the save — XML assembly and deflate, about two thirds of a write
— runs with the GIL released. The rows are read through Python objects and stay
serialised, which is why it is 1.7x and not 8x.
xlsxwriter is pure Python throughout and gets worse past two workers, from
65.40s to 159.41s. That is thread contention, not memory: free RAM never dropped
below 7.9 GB during the run and swap stayed at zero.
Without the GIL both spread properly. RustPy goes from 9.00s to 1.63s
(5.5x) and xlsxwriter from 71.54s to 19.72s (3.6x) — more of RustPy's
work is Rust rather than interpreted bytecode, so its advantage widens from 7.9x
at one worker to 12.1x at eight.
The cost is a single write being ~1% slower on 3.14t, the usual price of the
free-threaded interpreter. So: one big export is a wash, many concurrent exports
favour the free-threaded build — and either way more workers now helps.
Measured on 8 physical cores (16 threads), 16 GB, on a different machine than
the table above — read each row's columns against each other, not against the
rows above.
Two caveats: Polars has no free-threaded wheel yet, so that input path is
unavailable on 3.14t (Pandas, Arrow and records all work). And the free-threaded
build is younger — treat it as the newer option it is.
Key optimizations
Arrow zero-copy for DataFrames — reads memory buffers directly via Arrow C Data Interface (Excel and CSV paths)
First-row type caching for Records — detect column types once, skip type cascade
LTO (Link-Time Optimization) and single codegen unit
Constant memory mode for large files
Pre-allocated Format objects (created once, reused across all cells)
Dict values() iteration instead of per-key hash lookups
Lazy processing of Python iterables (including generators)
High-precision floating point with ryu
Efficient zlib compression
Features
Data Sources
List of dicts, generators/iterators, Pandas DataFrame, Polars DataFrame
All Python types: str, int, float, bool, None, datetime, date
Suppress error triangles (ignore_errors=), e.g. numbers stored as text
Output Options
.xlsx (Excel) — auto-detected from file extension
.csv / .tsv — auto-detected; ~5x faster than Python csv (records), ~12x faster than pandas.to_csv (Pandas DataFrame, via Arrow zero-copy)
io.BytesIO in-memory buffer, with output_format to put CSV in one
CSV byte order mark (bom=True) so Excel on Windows reads UTF-8
Column selection and ordering (columns=), header row toggle (header=)
Text for missing values and infinity (na_rep=, inf_value=)
Password protection (Excel only)
Optional column auto-fit (autofit=True, off by default)
Multiple sheets in a single file (Excel only)
Runtime
CPython 3.9+ — prebuilt wheels for Linux (glibc/musl), macOS, Windows
Free-threaded builds (python3.14t) — parallel writes, see Concurrency
API
Typed: ships py.typed, so mypy and Pyright check calls into it
Fluent builder via FastExcel class
Context manager (with statement) for auto-save
Lower-level functional API (write_worksheet, write_worksheets)
Quick Start
from rustpy_xlsxwriter import FastExcel
# One line
FastExcel("report.xlsx").sheet("Sheet1", records).save()
# Or with options
(
FastExcel("report.xlsx")
.format(float_format="0.00", bold_headers=True)
.freeze(row=1)
.sheet("Users", users)
.sheet("Orders", orders)
.save()
)
Everything else — formatting, charts, validation, printing, CSV options — is in
the documentation:
Openpyxl-compatible Excel library with a Rust backend: speed up openpyxl code with one import change and edit .xlsx templates without losing formatting, conditional formatting, or data validation. WolfXL 2.0.21 measured 6.7-12.0x faster than openpyxl 3.1.5 on the committed read/write benchmark (small-file gains vary). MIT.