ReadingResearchRadarInvestment framework
Sign in / Sign up
← Back to reading
NewsQuick take2 min readDisconfirmAI Editorial

Django Co-Founder Simon Willison: After Replacing strtod with Clinger's Fast Path, C Version of SQLite Extension Surpasses Rust

Simon Willison used Claude to implement C and Rust versions of the `parse_number()` SQLite extension. The initial Rust version led due to faster standard library floating-point parsing, but replacing C's `strtod` with Clinger's fast path optimized C to surpass Rust by approximately two times (16–19 ns/row), with 8 million fuzz tests confirming consistent results across all four implementations.

2026-11-09 06:26 GMT+8

Django co-founder Simon Willison had a specific question while walking his dog: could he write an SQLite extension function that parses strings like "-$1,234.56" or "'12.5%'" into numeric values that can be summed and sorted? He decided to use Claude (Opus 5.5) to simultaneously explore both C and Rust implementations, comparing performance, code complexity, and artifact size.

The initial results were contrary to his expectations. The Rust extensions were larger—the Rusqlite version was 321 KB and the sqlite-loadable-rs version was 298 KB—while the C extension was only 14 KB, yet Rust was actually faster. The reason was specific: the equivalent floating-point parsing implementation in the Rust standard library is about twice as fast as C's strtod, and the naive C implementation relied on this function to handle decimals.

He then issued a second prompt to Claude: write a custom C function to parse text into decimal numbers to catch up to or exceed Rust. Claude adopted Clinger's fast path—a known optimization strategy that skips general floating-point parsing overhead for common number formats. On 2 million rows of data, the optimized C version took 19 ns/row on mixed data (Rust was 41–46 ns), 16 ns/row on pure integers (Rust was 32–36 ns), and 18 ns/row on pure decimals (Rust was 47–55 ns), taking roughly half the time of Rust in each scenario.

All four implementations passed consistency checks from 8 million fuzz tests, confirming that the parsing results were identical.

This experiment demonstrates a verifiable pattern: when a performance bottleneck is pinpointed to a specific library function, language choice itself is not the decisive factor; targeted algorithmic replacement can bridge language-level gaps. AI's role here was not to discover new algorithms, but to implement a known technique under explicit instructions and verify its correctness.

Sign in / Sign up
ReadingResearchRadarInvestment framework

It should be noted that this was a first-party benchmark test covering only a specific scenario for a single function; the author did not claim the results generalize to broader C vs. Rust comparisons. Clinger's fast path itself is a known algorithm proposed in the 1990s, and its correctness has a broad foundation of practical application.

Sources

  • simonwillison.netSimon Willison’s Weblog↗
Continue researching →