# Claude wrote a SQLite number parser in C that runs twice as fast as the Rust versions

> Simon Willison asked Claude to compare C and Rust for a parse_number() extension. The Rust was faster until Claude wrote its own C decimal parser; all versions matched across 8M fuzz checks.

- URL: https://devisdead.ai/news/claude-wrote-a-sqlite-number-parser-in-c-that-runs-twice-as-fast-as-the-rust-ver
- Published: 2026-11-08T23:16:09Z
- Author: DevIsDead Newsroom
- Section: Dev
- Tags: sqlite, rust, c, claude
- Originally reported by Simon Willison's Weblog (https://simonwillison.net/2026/Nov/8/sqlite-parse-number-c-vs-rust/).

Simon Willison got curious while walking his dog: how hard would it be to add a parse_number() function to SQLite that converts text such as a dollar amount with commas or a percentage into numbers you can sum and sort? He handed the question to Claude, and wrote up what happened on [his weblog](https://simonwillison.net/2026/Nov/8/sqlite-parse-number-c-vs-rust/).

## The experiment

He asked Claude chat (Opus 5.5) to explore building the extension in C versus Rust, comparing speed, code complexity and the size of the compiled file. The first pass was a solid starting point. The C extension was tiny at 14 KB against roughly 300 KB for the two Rust builds (one with Rusqlite, one with sqlite-loadable-rs). But Rust was faster.

The reason turned out to be the standard library: Rust's equivalent of C's strtod parses decimals about twice as fast. So Willison asked Claude to write its own C decimal parser and beat Rust.

## The result

Cost per row, measured over 2 million rows:

- **Mixed data:** first C 67 ns, new C 19 ns, Rusqlite 46 ns, sqlite-loadable 41 ns.
- **Integers only:** 25, 16, 36 and 32 ns.
- **Decimals only:** 106, 18, 55 and 47 ns.

The rewritten C landed at 16 to 19 ns per row. That's roughly double the Rust builds' speed, and a long way ahead of stripping characters with SQL's replace(). All four implementations agreed across 8 million fuzz checks, with tests that checked types, parsing rules and float precision. Claude then turned the whole thing into a research report for Willison's research repository.

## Why it's worth noticing

This is the useful kind of AI coding: not a demo app, but a careful engineering question answered with benchmarks and fuzzing in the time it takes to walk a dog. The model did the grunt work, including a hand-rolled number parser most people would never bother writing.

The human part was knowing which question to ask next. "Why is Rust faster?" and "write your own and beat it" are the prompts that turned a toy into a result.

**[Scoreboard](/scoreboard) update:** AI +1. Claude hand-writes a C parser that doubles the speed of the Rust versions.

Stay undead.
