觉
AI觉醒星球
Awakening is here
Knowledge File / AI技能杠杆
2026-08-03 2 浏览 免费阅读

condense-json 1.0 发布

Simon Willison 宣布发布 condense-json 1.0,一个用于压缩 JSON 中重复字符串的 Python 库,可节省 LLM 日志的存储空间。

SOURCE / AI技能杠杆 MIN / 4 ACCESS / 免费阅读 POST / 2026-08-03 06:19:59

原贴

查看原文
作者:Simon Willison 来源站点:simonwillison.net 原贴时间:

原文

Release: condense-json 1.0 I'm trying to get braver at releasing 1.0 versions. This little library is a year and a half old now - I've applied some sensible and non-disruptive fixes and shipped the big 1.0 for it. Here's an example of what it can do, lifted from the README: { "foo" : { "bar" : { "string" : " This is a string with foxes in it " , "nested" : { "more" : [ " Here is a string " , " another with foxes in it too " ] } } } } Combine that with a replacements object: { "1" : " with foxes in it " } And condense_json(input_json, replacements) produces the following: { "foo" : { "bar" : { "string" : { "$r" : [ " This is a string " , { "$" : " 1 " }]}, "nested" : { "more" : [ " Here is a string " , { "$r" : [ " another " , { "$" : " 1 " }, " too " ]}] } } } } It scans for strings or substrings that are present in that replacements object and replaces those with a special {"$r": ...} syntax in the output. You can reverse the effect with uncondense_json(condensed, replacements) . The idea is to make it easier to store JSON that includes duplicated data from other related structures. I use it to save space in the SQLite logs generated by LLM - see PR #1586 for the latest iteration of that. Tags: json , projects , python , llm

中文翻译

发布:condense-json 1.0 我正在尝试更勇敢地发布 1.0 版本。这个库已经有一年半的历史了——我应用了一些明智且非破坏性的修复,并为其发布了重要的 1.0 版本。以下是从 README 中摘录的一个示例: { "foo" : { "bar" : { "string" : " This is a string with foxes in it " , "nested" : { "more" : [ " Here is a string " , " another with foxes in it too " ] } } } } 将其与一个替换对象组合: { "1" : " with foxes in it " } 然后 condense_json(input_json, replacements) 产生以下结果: { "foo" : { "bar" : { "string" : { "$r" : [ " This is a string " , { "$" : " 1 " }]}, "nested" : { "more" : [ " Here is a string " , { "$r" : [ " another " , { "$" : " 1 " }, " too " ]}] } } } } 它扫描出现在该替换对象中的字符串或子字符串,并在输出中用特殊的 {"$r": ...} 语法替换它们。你可以使用 uncondense_json(condensed, replacements) 反转效果。这样做的目的是使存储包含来自其他相关结构的重复数据的 JSON 更加容易。我用它来节省 LLM 生成的 SQLite 日志中的空间——参见 PR #1586 以获取最新迭代。 标签:json , projects , python , llm

核心信息

Simon Willison 宣布发布 condense-json 1.0,一个用于压缩 JSON 中重复字符串的 Python 库,可节省 LLM 日志的存储空间。

  • Simon Willison 宣布发布 condense-json 1.0,一个用于压缩 JSON 中重复字符串的 Python 库,可节省 LLM 日志的存储空间。
  • 原贴提到:Release: condense-json 1.0 I'm trying to get braver at releasing 1.0 ver
  • 来源:simonwillison.net

详细解读

这是一个信号:小型工具库开始重视 1.0 版本的稳定性与实用性。condense-json 通过将重复子串替换为占位符,在存储和传输 JSON 时显著节省空间,尤其适用于 LLM 应用场景中大量结构相似的日志或缓存数据。

为什么重要:在 LLM 驱动的应用中,SQLite 日志往往包含大量重复的提示词片段或固定模板,这些冗余数据会快速膨胀数据库。condense-json 提供了一种可逆的压缩方案,开发者可以在写入时压缩、读取时还原,而不损失任何信息。这种思路与数据去重、字典编码等经典技术一脉相承,但专门针对 JSON 这种半结构化格式进行了优化。

对谁有价值:主要面向需要持久化 LLM 交互记录、构建数据管道的后端开发者,以及任何在 JSON 中存储大量重复文本的工程师。它也可以作为 Python 生态中一个轻量级的工具库,集成进现有的数据处理流程。

可以怎么行动:如果你正在使用 SQLite 记录 LLM 输出,可以尝试在写入前用 condense_json 压缩 "text" 字段,并在读取时 uncondense_json 还原。也可以将替换表动态构建为高频出现的子串,以最大化压缩率。还可以关注 PR #1586 中作者的实际用法,评估其效果。

风险或限制:该库的压缩效率高度依赖替换表的质量,如果重复子串不频繁,反而会增加开销。此外,替换表本身需要额外存储,且替换逻辑可能对特殊字符或嵌套结构敏感,使用前应在真实数据上测试。目前是 1.0 版本,API 可能仍会调整,但基本功能已稳定。

信息差价值

这条内容的真正价值,不只是“有人发布了一个新功能”,而是它揭示了 simonwillison.net 背后的产品方向、工作流变化或竞争信号。对 OPC 来说,这种信息可以转化成持续追踪的栏目选题。

如果把《condense-json 1.0 发布》放到你的内容系统里,它最大的价值在于帮助读者更快看懂“为什么值得关注”,而不是只看到一条碎片化动态。

参考来源

AI SUMMARY

这篇文章回答了什么

condense-json 1.0 发布主要讲什么?

Simon Willison 宣布发布 condense-json 1.0,一个用于压缩 JSON 中重复字符串的 Python 库,可节省 LLM 日志的存储空间。

这篇文章最值得关注的要点是什么?

Simon Willison 宣布发布 condense-json 1.0,一个用于压缩 JSON 中重复字符串的 Python 库,可节省 LLM 日志的存储空间。;原贴提到:Release: condense-json 1.0 I'm trying to get braver at releasing 1.0 ver;来源:simonwillison.net

这篇文章和哪些AI专题相关?

它适合放在Agent工作流、AI超级个体、AI副业专题里阅读。 关联原因:这篇内容命中「Agent、工作流」等主题信号。;这篇内容命中「技能」等主题信号。;这篇内容命中「项目」等主题信号。

阅读这篇文章建议先理解哪些关键词?

建议先理解工具、Cursor、Agent、智能体、工作流这些关键词,再结合正文判断工具、机会或风险是否值得进入自己的工作流。

上一篇 Claude Code 连接器可复用至 Artifacts 下一篇 关于Simon Willison的“自行车上的鹈鹕”测试,以及Karpathy的《指环王》电影实验