This repository was archived by the owner on Nov 22, 2026. It is now read-only.
Repository navigation
mojo-csv v0.1.1
mojo-csv v0.1.1
Released: 2026-11-07 · Commit: the one tagged v0.1.1 · Previous: v0.1.0
What it does
CSV reader and writer for Mojo byte buffers, with CPython 3.14 quoting rules.
Unquoted fields view the input as Spans; quoted and escaped fields use retained
row scratch. Supports six quoting modes, distinct None and empty string
preservation, invalid UTF-8 passthrough, and ASCII float validation.
Highlights
write_allis 1.9x faster: 242.5 -> 468.2 MB/s on 714285 records (CPythoncsv.writeron the same rows: 97.1 MB/s).write_allpeaks 36 MB lower on that input (326328 -> 290052 KB): the output is reserved once, with no doubling copies.Dialect(escapechar=...)now enables escaping. Before, the byte was ignored withouthas_escape=True.- No reader change: 840k random reader cases, 350k writer cases and 50k
line_numcases agreed with CPython 3.14.8.
Changes
Changed
write_all: one 256-byte stack table flags special bytes, fields without one are copied with a singleextend, and the output is reserved from the field byte sum.scripts/nightly.shrequiresMOJO(no machine path);scripts/benchmark.shalternates Mojo and CPython rounds itself and adds the write mode.
Fixed
- A nonzero
escapecharpassed withouthas_escape=Truewas silently ignored, soa\,bsplit into two fields.has_escape=Trueis now only needed for a NUL escape.
Verified
| Check | Result |
|---|---|
scripts/ci.sh: build, goldens, mutants, API, quickstart, two differentials |
PASS 6/6, PASS ci |
scripts/check.sh: CPython golden vectors (tests/test_golden.mojo, 1255 rows, 6 new writer rows) |
PASS golden 1255 |
tests/test_limit.mojo: 131072 boundary for quoted, doubled-quote, escaped and CRLF fields |
PASS limit |
tests/test_dialect.mojo: escapechar inference (fails on v0.1.0: left 2, right 1) |
PASS dialect |
scripts/mutants.sh: 16 compiling behavior mutants |
16/16 killed, 0 invalid |
tools/oracle_fuzz.py and tools/oracle_write_fuzz.py: 20000 random cases each vs CPython 3.14, seed 7 |
0 diffs |
scripts/nightly.sh on Mojo 1.3.0.dev2026110305 |
PASS nightly |
write A/B: 7 alternating rounds, CPU 7 (docs/benchmarks/csv-writer.txt) |
242.5 -> 468.2 MB/s median |
Known limits
- Byte buffers only: no Python file or streaming chunk abstractions. Sniffer, DictReader and DictWriter are excluded.
- Field limit is 131072 bytes, not codepoints. Numeric syntax is ASCII. Error messages are library-specific.
- Row and field views expire at the next
next()orreset(); the compiler does not reject invalid retention. row[index]has no bounds check in release builds.OwnedFieldrows cost about 64 bytes per small field onread_all(240732 KB for 50 MB); streaming withrow()stays at 58288 KB.- Tried and reverted: quoted fields as input views (+0.9% stream, 0% owned), SIMD width 32 (-7%) and 8 (+3%).
Upgrade / run
git clone https://github.com/amarbaro/mojo-csv && cd mojo-csv && uv sync
scripts/cap.sh .venv/bin/mojo run -I src examples/quickstart.mojoUpgrade from v0.1.0: no API change. Code that passed only escapechar= now gets escaping.
Commits
git log v0.1.0..v0.1.1