Simon Willison investigated implementing a SQLite parse_number() extension to convert formatted strings (e.g., "-$1,234.56", "12.5%") into numeric values, comparing C and Rust implementations with assistance from Claude Opus 5.5. The Rust extensions, built using Rusqlite and sqlite-loadable-rs, produced shared libraries of 321 KB and 298 KB respectively, while the C version was only 14 KB. Despite larger binary size, Rust initially outperformed C due to its strtod equivalent being roughly twice as fast. To close the gap, a custom C parser implementing Clinger's fast path algorithm was developed. Benchmarking over 2 million rows showed the optimized C implementation achieved the lowest per-row latency across all data types: 19 ns for mixed data, 16 ns for integers only, and 18 ns for decimals only. In contrast, the original C version ranged from 25–106 ns, Rusqlite from 36–55 ns, and sqlite-loadable-rs from 32–47 ns. The investigation was formalized into a research report added to the simonw/research repository.

Read original