Lune

ICSE2023Top-tier venue

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

Zejun Zhang, Zhenchang Xing, Xin Xia, Xiwei Xu, Liming Zhu, Qinghua Lu

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.

Ask Lune

Know this paper in minutes, not an afternoon.

Lune can read every page of it and the top-tier papers that cite it, and gives you its claims, its evidence and its limits, each one cited to the paper it comes from. No skimming, no AI slop.

5 top-tier papers have cited it since. Know what they found before your reviewers do.

Questions to start from

Lune can draw on

the full paper · the top-tier papers that cite it · related work

Get the answer

Free to start. No credit card required.

Lineage

  • AI-driven Java Performance Testing: Balancing Result Quality with Testing Time cites Towards the use of the readily available tests from the release pipeline as performance tests: are we there yet?
  • A Study on the Pythonic Functional Constructs' Understandability cites Making Python code idiomatic by automatic refactoring non-idiomatic Python code with pythonic idioms
  • Refactoring to Pythonic Idioms: A Hybrid Knowledge-Driven Approach Leveraging Large Language Models cites Making Python code idiomatic by automatic refactoring non-idiomatic Python code with pythonic idioms
  • DyLin: A Dynamic Linter for Python cites DyPyBench: A Benchmark of Executable Python Software
Builds onCited byLeft to right by year; the more cited, the higher.

Cited by top-tier papers5

  1. AI-driven Java Performance Testing: Balancing Result Quality with Testing TimeLuca Traini, Federico Di Menna, Vittorio CortellessaASE 2024 · 12 citations
  2. Refactoring to Pythonic Idioms: A Hybrid Knowledge-Driven Approach Leveraging Large Language ModelsZejun Zhang, Zhenchang Xing, Xiaoxue Ren, Qinghua Lu et al.FSE 2024 · 11 citations
  3. DyPyBench: A Benchmark of Executable Python SoftwareIslem Bouzenia, Bajaj Piyush Krishan, Michael PradelFSE 2024 · 8 citations
  4. A Study on the Pythonic Functional Constructs' UnderstandabilityCyrine Zid, Fiorella Zampetti, Giuliano Antoniol, Massimiliano Di PentaICSE 2024 · 4 citations
  5. DyLin: A Dynamic Linter for PythonAryaz Eghbali, Felix Burk, Michael PradelFSE 2025 · 1 citation

Builds on3

  1. Making Python code idiomatic by automatic refactoring non-idiomatic Python code with pythonic idiomsZejun Zhang, Zhenchang Xing, Xin Xia, Xiwei Xu et al.FSE 2022 · 35 citations
  2. Towards the use of the readily available tests from the release pipeline as performance tests: are we there yet?Zishuo Ding, Jinfu Chen, Weiyi ShangICSE 2020 · 33 citations
  3. An Exploratory Study of Deep learning Supply ChainXin Tan, Kai Gao, Minghui Zhou, Li ZhangICSE 2022 · 32 citations

Related papers

  1. Hard to Read and Understand Pythonic Idioms? DeIdiom and Explain Them in Non-Idiomatic Equivalent CodeZejun Zhang, Zhenchang Xing, Dehai Zhao, Qinghua Lu et al.ICSE 2024 · 7 citations
  2. Learning to find naming issues with big code and small supervisionJingxuan He, Cheng-Chun Lee, Veselin Raychev, Martin T. VechevPLDI 2021 · 9 citations
  3. Exploring how deprecated Python library APIs are (not) handledJiawei Wang, Li Li, Kui Liu, Haipeng CaiFSE 2020 · 52 citations
  4. Understanding Performance Concerns in the API Documentation of Data Science LibrariesYida Tao, Jiefang Jiang, Yepang Liu, Zhiwu Xu et al.ASE 2020 · 8 citations
  5. Language Models for Code Completion: A Practical EvaluationMaliheh Izadi, Jonathan Katzy, Tim van Dam, Marc Otten et al.ICSE 2024 · 51 citations
Dusk over the sea between two cliffs drawn in fine vertical lines