RC RANDOM CHAOS

SQLite parse_number(): C vs Rust Performance Compared

· via Simon Willison

Original source

parse_number() as a SQLite extension: C vs Rust

Simon Willison →

Simon Willison investigated building a SQLite parse_number() function, comparing C and Rust implementations. Using Claude (Opus 5.5), he specified a function to strip currency symbols, commas, and percentages while handling negative values and returning NULL for unparseable input. The investigation compared performance, code complexity, and output file size.

Rust implementations produced significantly larger files—321 KB with Rusqlite and 298 KB with sqlite-loadable-rs—compared to 14 KB for the C extension. Initially, the Rust version demonstrated faster performance because its string-to-decimal conversion routine outperformed C’s standard library function by a factor of two. Willison then prompted Claude to develop an optimized C parser aimed at matching Rust’s speed, resulting in a performance comparison across 2 million rows.

Read the full article

Continue reading at Simon Willison →

This is an AI-generated summary. Read the original for the full story.