condense-json 1.0

Simon Willison's Blog 工具

摘要

Simon Willison 宣布 condense-json 1.0 发布,这是一个 Python 库,通过用紧凑引用替换重复子串来压缩 JSON,从而为 LLM 节省 SQLite 日志空间。

暂无内容
查看原文
查看缓存全文

缓存时间: 2026/08/03 01:28

# 发布:condense-json 1.0 来源:https://simonwillison.net/2026/Aug/2/condense-json/ 我正在尝试在发布 1.0 版本时更大胆一些。这个小库已经有一年半的历史了——我应用了一些合理且无破坏性的修复,并为它发布了 1.0 这个大版本。 以下是一个从 README 中摘录的示例,展示了它的功能: ```json { "foo": { "bar": { "string": "This is a string with foxes in it", "nested": { "more": ["Here is a string", "another with foxes in it too"] } } } } ``` 将其与一个 replacements 对象结合: ```json {"1": "with foxes in it"} ``` 然后 `condense_json(input_json, replacements)` 会产生以下结果: ```json { "foo": { "bar": { "string": {"$r": ["This is a string ", {"$": "1"}]}, "nested": { "more": ["Here is a string", {"$r": ["another ", {"$": "1"}, " too"]}] } } } } ``` 它会扫描 replacements 对象中存在的字符串或子字符串,并用特殊的 `{"$r": ...}` 语法在输出中替换它们。 你可以使用 `uncondense_json(condensed, replacements)` 来反转这一效果。 这个想法是为了更容易地存储包含来自其他相关结构的重复数据的 JSON。我用它来节省 [LLM](https://llm.datasette.io/) 生成的 SQLite 日志中的空间——有关最新迭代,请参阅 [PR #1586](https://github.com/simonw/llm/pull/1586)。

相似文章

condense-json 1.1

Simon Willison's Blog

condense-json 1.1 为对象增加了结构替换和合并操作,并添加了使用 Hypothesis 的基于属性的往返测试。

SQLite压缩文本历史原型

Simon Willison's Blog

Simon Willison试验将SQLite文本修订历史存储为压缩的JSON数组,比较了整体blob和分块存储方法。一项模拟1000次编辑的测试,使用Zstandard将20.4 MB的修订文本压缩为80.3 KB。

SQLite 3.53.0

Simon Willison's Blog

SQLite 3.53.0 发布,带来重要的累积改进,包括 ALTER TABLE 约束修改、新的 JSON 函数(json_array_insert),以及通过新的查询结果格式化库实现的重大 CLI 模式增强。

datasette 1.0a41

Simon Willison's Blog

Datasette 1.0a41 版本发布,这是一款数据探索与发布工具的版本更新,由 Simon Willison 宣布,详细介绍了其集成方式与赞助情况。

sqlite-utils 4.0

Simon Willison's Blog

sqlite-utils 4.0 已发布,这是一个用于操作 SQLite 数据库的 Python 库。