Sunday, November 22, 2026Sun, Nov 22 AboutRSSSubscribe

Content Memory

Knowledge, search and the machines that remember

Developer Tools

parse_number() as a SQLite extension: C vs Rust

Simon Willison researched SQLite extensions in C and Rust, comparing performance and code complexity. The optimized C implementation proved fastest.

Original reporting · simonwillison.net

Read “parse_number() as a SQLite extension: C vs Rust” at Simon Willison →

How this was written. Content Memory wrote this article with a language model from Simon Willison’s reporting (model: @cf/meta/llama-3.3-70b-instruct-fp8-fast); it describes that reporting rather than adding to it. The original, linked above, is the full story.

Key points from Simon Willison’s report

  • Simon Willison researched SQLite extensions in C and Rust to compare performance and code complexity.
  • The optimized C implementation proved to be the fastest at 16–19 ns per row.
  • The Rust extension was larger in size, but initial findings suggested it was faster, although this was later contradicted.
  • The plain C implementation was slower on decimals due to reliance on strtod(), but a compact fast path closed this gap.
  • All versions of the extension matched across 8 million fuzz checks, ensuring their accuracy.

Simon Willison, according to his research, explored the possibility of creating a SQLite extension that adds a parse_number() function, which can turn strings like -$1,234.56 or '12.5%' into numeric values. This function would be useful for summing and sorting such values. The goal was to compare the performance and code complexity of building this extension in C versus Rust.

The research involved implementing the same parse_number() behavior in C and Rust, with tests covering type preservation, parsing rules, and floating-point accuracy. Four SQLite extensions were created, with the optimized C implementation being the fastest at 16–19 ns per row. This was about twice as fast as the Rust versions and far faster than SQL replace().

The plain C implementation was initially slower on decimals because it relied on strtod(), but a compact fast path was able to close this gap. All versions of the extension matched across 8 million fuzz checks, ensuring their accuracy. This research provides valuable insights into the performance differences between C and Rust implementations of SQLite extensions.

The idea for this research came to Simon Willison while walking his dog, prompting him to investigate the feasibility of writing a SQLite C extension. He used a chat service, Opus 5.5, to explore the difference between building the extension in C versus Rust. The goal was to compare performance, code complexity, and the size of the resulting file.

The results showed that the Rust extension was larger in size, with Rusqlite and sqlite-loadable-rs resulting in files of 321 KB and 298 KB, respectively. In contrast, the C extension was significantly smaller at 14 KB. However, the initial findings suggested that the Rust extension was faster, which seemed counterintuitive given the size difference.

Further investigation revealed that the optimized C implementation was indeed the fastest, outperforming the Rust versions. This outcome highlights the importance of optimizing code for performance, regardless of the programming language used. The research demonstrates that C can still offer significant performance advantages in certain scenarios.

The comparison of SQLite extensions in C and Rust provides valuable information for developers considering the implementation of custom functions in their databases. The findings can inform decisions about the choice of programming language and the optimization of code for performance.

Questions and answers

What prompted Simon Willison to research SQLite extensions?

Simon Willison was prompted to research SQLite extensions while walking his dog, when he got curious about writing a SQLite C extension that adds a parse_number() function.

How did the size of the C and Rust extensions compare?

The C extension was significantly smaller at 14 KB, while the Rust extensions were 321 KB and 298 KB using Rusqlite and sqlite-loadable-rs, respectively.

Which implementation proved to be the fastest?

The optimized C implementation proved to be the fastest at 16–19 ns per row, outperforming the Rust versions.

Read the full story at Simon Willison More from Monday, November 9, 2026’s edition