paperbot · PL 论文追踪

全部论文 待读 收藏

P2 Faster or Slower? Performance Mystery of Python Idioms Unveiled with Empirical Evidence

更快还是更慢?用经验证据揭开 Python 惯用法的性能谜团
ICSE 2023 IEEE/ACM 45th International Conference on Software Engineering (ICSE)2023匹配度 2/10 · 论文关注 Python 惯用法的运行时性能与字节码层面的经验分析,属于 PL/软件工程的经验研究,但未涉及用户核心关注的静态分析、LLM/Agent、浮点程序分析或贝叶斯程序分析。引用 21 inbox
Zejun Zhang, Zhenchang Xing, Xin Xia, Xiwei Xu, Liming Zhu, Qinghua Lu
crossref: 2026-09-12dblp: 2026-09-12arxiv: 2026-09-12

AI 速览

一句话:通过大规模合成与真实项目数据,系统测量并字节码级解释 Python 惯用法相对非惯用写法的性能差异。

Python 开发者常对惯用法(idioms)的性能影响感到困惑,现有讨论多依赖轶事式玩具代码或个人项目经验,结果相互矛盾,缺乏大规模系统证据。本文为九种 Python 惯用法构建了 24,126 对非惯用法与功能等价的惯用法代码合成数据集,并复用包含 54,879 对代码的真实项目数据集;作者设计可靠的性能测量方法,比较惯用法相对非惯用法带来的加速或减速,分析合成代码与真实项目代码的性能差异、代码特征与性能变化的关系,并在字节码层面追溯性能变化的根因。最后总结出可操作的 Python 惯用法使用建议。

问题
Python 开发者对惯用法的性能影响存在普遍困惑,既有讨论多基于轶事或经验,且结论矛盾,缺少大规模、系统性的经验证据来澄清这些性能争议。
方法
构建九种 Python 惯用法的大规模合成代码对数据集,并复用大规模真实项目代码对数据集;设计可靠的性能测量方法,结合代码特征分析与字节码级分析来比较性能差异并追溯根因。
评估
在 24,126 对合成代码和 54,879 对真实项目代码上测量惯用法相对非惯用法的加速或减速,分析合成与真实项目间的性能差异及其与代码特征的关系,并给出可操作的使用建议。
原文摘要(Abstract)

The usage of Python idioms is popular among Python developers in a formative study of 101 Python idiom performance related questions on Stack Overflow, we find that developers often get confused about the performance impact of Python idioms and use anecdotal toy code or rely on personal project experience which is often contradictory in performance outcomes. There has been no large-scale, systematic empirical evidence to reconcile these performance debates. In the paper, we create a large synthetic dataset with 24,126 pairs of non-idiomatic and functionally-equivalent idiomatic code for the nine unique Python idioms identified in [1], and reuse a large real-project dataset of 54,879 such code pairs provided in [1]. We develop a reliable performance measurement method to compare the speedup or slowdown by idiomatic code against non-idiomatic counterpart, and analyze the performance discrepancies between the synthetic and real-project code, the relationships between code features and performance changes, and the root causes of performance changes at the bytecode level. We summarize our findings as some actionable suggestions for using Python idioms.

链接与引用

DOI 原文 · arXiv · PDF(开放获取) · DBLP

BibTeX
@inproceedings{ZhangXXXZL23,
  title = {Faster or Slower? Performance Mystery of Python Idioms Unveiled with Empirical Evidence},
  author = {Zejun Zhang and Zhenchang Xing and Xin Xia and Xiwei Xu and Liming Zhu and Qinghua Lu},
  booktitle = {ICSE},
  year = {2023},
  doi = {10.1109/icse48619.2023.00130}
}