返回全部动态

parse_number() 作为 SQLite 扩展:C 与 Rust 对比

原标题:parse_number() as a SQLite extension: C vs Rust

Simon Willison's Weblog研究质量 59

AI 摘要

Simon Willison 在遛狗时产生想法,用 Claude Opus 5.5 探索为 SQLite 编写 parse_number() 自定义函数,比较 C 与 Rust 扩展在性能、代码复杂度和产物大小上的差异。初步结果显示 Rust 扩展(321KB/298KB)远大于 C 扩展(14KB),但 Rust 版本更快,原因是其 strtod 等价实现速度约为 C 的两倍。随后他让 Claude 手写 C 解析函数,新 C 实现在混合数据、纯整数、纯小数场景下均反超 Rust 实现。最后他将调查整理为 simonw/research 仓库中的研究报告。

以上摘要由 AI 生成,可能存在误差。事实请以原文为准。

正文节选

8th November 2026 I was out walking the dog when I got curious about how easy/difficult it would be to write a SQLite C extension that adds a parse_number() function for turning strings like -$1,234.56 or '12.5%' into numeric values that could be summed and sorted. I fired up regular Claude chat (Opus 5.5) and prompted: I'm thinking about a SQLite custom function 'parse_number(value)' that strips ',', '$', '£' and '%', handles a leading '-', and returns 'NULL' for anything it can’t parse Explore


发布时间:2026-11-09 06:26
抓取时间:2026-11-09 06:55
来源机构:Simon Willison
阅读原文simonwillison.net