Urgent.News

What's breaking now, across thousands of outlets.

World

parse_number() as a SQLite extension: C vs Rust

A reporter set out to investigate the ease of creating a SQLite extension that includes a function for parsing strings into numeric values, such as -$1,234.56 or 12.5%. The reporter used Claude chat (Opus 5.5) to prompt the idea of a custom function named parse_number(value) that would strip out characters like commas, currency symbols, and percentages, as well as handle negative signs.

The reporter was curious to compare the performance of building this extension in C versus Rust, as well as the complexity and size of the resulting .so file.

The results showed that the Rust implementation was significantly faster, with the Rust extension being 321 KB (using Rusqlite) and 298 KB (using sqlite-loadable-rs), while the C extension was only 14 KB. This performance difference was attributed to the Rust equivalent of C's strtod being twice as fast. The reporter then proceeded to write their own C function to see if it could match or surpass the Rust implementation when parsing text into decimal numbers.

The net cost per row when processing 2 million rows was compared, with the lower cost being preferred. Finally, the reporter aimed to turn their investigation into a research report, following the format used in the simonw/research repository.

Written by urgent.news from Simon Willison's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

This story

This is one outlet's version. Read the fullest account.

Read the original at substack.com →

More in World

More from Tuesday 10 November →