论文精选

LLM辅助零依赖Python库:stdlib能否替代第三方?

Stdlib or Third-Party? Empirical Performance and Correctness of LLM-Assisted Zero-Dependency Python Libraries

精选理由

Python开发者面临依赖管理痛点,这项研究用数据告诉你哪些第三方库可以用stdlib替代,哪些不行。做轻量级部署或减少供应链风险的团队,值得参考zerodep的实践。

AI 摘要

一项实证研究通过zerodep项目,用LLM辅助开发了40多个仅依赖Python标准库的模块,替代流行的第三方库。基准测试显示,大多数情况下stdlib实现性能与第三方库持平(2倍以内),但在C扩展支持的计算任务(如图像处理、二进制序列化)中性能差距明显。有趣的是,许多第三方库因架构开销反而比stdlib实现慢5-115倍。该研究揭示了stdlib的能力边界,并探讨了LLM在严格约束下生成正确、高效代码的可行性。

原文 · arXiv cs.AI

Stdlib or Third-Party? Empirical Performance and Correctness of LLM-Assisted Zero-Dependency Python Libraries

Third-party Python libraries introduce dependency management overhead, supply chain risk, and deployment friction in constrained environments. A natural question is how much of this ecosystem can be replicated using only Python's standard library -- and at what correctness and performance cost. We address this empirically through zerodep, a growing collection of single-file Python modules, each a stdlib-only reimplementation of a popular third-party library, developed with LLM assistance under strict constraints: no external imports, single file, drop-in API compatibility, and mandatory correctness validation against the reference library. Spanning over 40 modules across 12 categories -- including serialization, networking, cryptography, agent protocols, and text processing -- zerodep provides a controlled testbed for two interrelated questions: (1) Where does the stdlib suffice? and (2) Can LLMs effectively generate correct, performant code under tight symbolic constraints? Systematic benchmarking shows that stdlib-only implementations achieve performance parity (within 2x of the reference) in the majority of cases. The primary performance cliff is C-extension-backed computation (image processing, binary serialization, low-level crypto), not the inherent overhead of pure-Python third-party libraries. Conversely, many widely-used libraries carry architectural overhead that LLM-generated stdlib reimplementations avoid, yielding 5--115x speedups in several categories. We characterize the stdlib capability boundary across complexity tiers and library categories, discuss where LLM-assisted development succeeds and where it requires iterative human correction, and examine implications for dependency-free software engineering at scale. zerodep is open-source at https://github.com/Oaklight/zerodep.