News ·
parse_number() as a SQLite extension: C vs Rust
Simon Willison used Claude (Opus 5.5) to compare SQLite parse_number() extensions in C vs Rust, finding Rust initially faster but an optimized C version using Clinger's fast path became the quickest.
Simon Willison built a SQLite custom function called parse_number() that converts formatted strings like -$1,234.56 or '12.5%' into numeric values that can be summed and sorted, returning NULL for unparseable input. He prompted Claude Opus 5.5 to explore building the same extension in both C and Rust, comparing performance, code complexity, and binary size.
The initial results showed large size differences: the Rust extension came to 321 KB using Rusqlite and 298 KB using sqlite-loadable-rs, while the C version was just 14 KB. Surprisingly, the Rust version was faster, apparently because Rust's equivalent of C's strtod is described as twice as fast. Willison then prompted Claude to write its own C decimal-parsing function to catch up or beat Rust, and it did so using Clinger's fast path. The optimized C implementation was fastest at 16-19 net cost per row over 2 million rows. Four extensions implement the same behavior, with tests covering type preservation, parsing rules, and floating-point accuracy.
For developers building with AI, this is a practical example of an iterative prompting workflow: ask for a comparison, notice an unexpected result, then request a targeted optimization that outperforms the baseline. It also shows that LLMs can produce compact, fast C extensions for SQLite, and that Willison had the final work rewritten into a research report format by cloning his simonw/research repository and asking for a matching writeup delivered as a zip file.
References
- Simon Willison · simonwillison.net
Read the full story at Simon Willison ↗Like, save or discuss on Buzz


