AI Weekly Malaysia

Back to items Summaries

parse_number() as a SQLite extension: C vs Rust

ID
44431
Status
summarized
Published
09 Nov 2026, 6:26 AM
Fetched
10 Nov 2026, 8:37 AM
Provider
Simon Willison
Category
developer-ai
Original URL
https://simonwillison.net/2026/Nov/8/sqlite-parse-number-c-vs-rust/
Source URL
https://simonwillison.net/atom/everything/

Summary

Score
6.5
Created
10 Nov 2026, 8:38 AM
Tags
Audience
developersvibe_codersdatabase_learners

What happened

Simon Willison benchmarked four SQLite extensions that add a parse_number() function (stripping ',', '$', '£', '%' and handling leading '-') implemented in C and Rust, testing type preservation, parsing rules and float accuracy across 8 million fuzz checks with identical results. The naive C version lost on decimals because it leaned on strtod(), but a hand-written fast path brought it to 16–19 ns per row — roughly twice as fast as the Rusqlite (46/36/55 ns) and sqlite-loadable-rs (41/32/47 ns) versions and far ahead of SQL replace(). The C extension also compiles to 14 KB versus 298–321 KB for the Rust builds, and the whole investigation was driven through Claude Opus 5.5 prompts, ending as a report in simonw/research.

Why it matters

If you clean currency or percentage strings in bulk inside SQLite, this gives you a concrete decision: a custom C parse_number() extension costs ~14 KB and runs at 16–19 ns/row versus 41–55 ns for the Rust loadable extensions and dramatically slower chained replace() calls. It also warns against shipping the first plausible benchmark — the initial run made Rust look faster only because its float parsing beat C's strtod(), which a compact fast path erased.

Discussion angle

Ask where else the 'Rust is faster than C' assumption breaks down once you write the hot path by hand — and how you'd structure an AI-assisted benchmark loop so you don't stop at the first result that looks convincing.

Top