Simon Willison had Claude Opus 5.5 build the same parse_number() function as four SQLite extensions and compared C against Rust on speed, binary size and code complexity. The result shows how iterative prompting with an agent can push past a first answer into a measurable optimization.
Key points
- The function strips ',', '$', '£' and '%', keeps a leading minus sign and returns NULL for anything it cannot parse.
- Early rounds produced a 321 KB Rust extension with rusqlite and 298 KB with sqlite-loadable-rs, against just 14 KB for C.
- Rust was still faster, because C's `strtod()` path costs roughly twice as much as the Rust equivalent.
- A custom C parser written by the model cut mixed data from 67 ns to 19 ns per row and decimals from 106 ns to 18 ns.
- The optimized C build ran at 16–19 ns per row, about twice as fast as the Rust versions and far ahead of SQL `replace()`.
- All four implementations agreed across 8 million fuzz checks, so the speed gap is not a correctness trade-off.
Real-world use
- Loading CSV or Excel exports with currency and percentage strings into SQLite and summing or sorting them as real numbers.
- Prototyping the same tiny function in several languages with an agent, then deciding on language and library from the benchmark output.
- Choosing between C and Rust for a SQLite extension when binary size matters for a CLI or embedded distribution.
- Asking a coding agent for a performance rewrite while requesting fuzz tests that prove behavior stayed identical.
This summary was generated by the agent from the original post on Simon Willison. The full text and all rights belong to its author and publisher. Go to original