Nothing Special   »   [go: up one dir, main page]

skip to main content
10.1145/3524610.3527879acmconferencesArticle/Chapter ViewAbstractPublication PagesicseConference Proceedingsconference-collections
short-paper

Does coding in Pythonic zen peak performance?: preliminary experiments of nine Pythonic idioms at scale

Published: 20 October 2022 Publication History

Abstract

In the field of data science, and for academics in general, the Python programming language is a popular choice, mainly because of its libraries for storing, manipulating, and gaining insight from data. Evidence includes the versatile set of machine learning, data visualization, and manipulation packages used for the ever-growing size of available data. The Zen of Python is a set of guiding design principles that developers use to write acceptable and elegant Python code. Most principles revolve around simplicity. However, as the need to compute large amounts of data, performance has become a necessity for the Python programmer. The new idea in this paper is to confirm whether writing the Pythonic way peaks performance at scale. As a starting point, we conduct a set of preliminary experiments to evaluate nine Pythonic code examples by comparing the performance of both Pythonic and Non-Pythonic code snippets. Our results reveal that writing in Pythonic idioms may save memory and time. We show that incorporating list comprehension, generator expression, zip, and itertools.zip_longest idioms can save up to 7,000 MB and up to 32.25 seconds. The results open more questions on how they could be utilized in a real-world setting. The replication package includes all scripts, and the results are available at https://doi.org/10.5281/zenodo.5712349

References

[1]
2021. Glossary --- Python 3.10.0 documentation. https://docs.python.org/3/glossary.html#Pythonic. (Accessed on 11/17/2021).
[2]
2022. memory-profiler • PyPI. https://pypi.org/project/memory-profiler/. (Accessed on 03/18/2022).
[3]
2022. researchpy - PyPI. https://pypi.org/project/researchpy/. (Accessed on 03/18/2022).
[4]
Carol V. Alexandru, José J. Merchante, Sebastiano Panichella, Sebastian Proksch, Harald C. Gall, and Gregorio Robles. 2018. On the Usage of Pythonic Idioms. In ACM SIGPLAN International Symposium on New Ideas, New Paradigms, and Reflections on Programming and Software (Onward! 2018). 1--11.
[5]
Aamir Farooq and Vadim Zaytsev. 2021. There Is More Than One Way to Zen Your Python. In ACM SIGPLAN International Conference on Software Language Engineering (SLE).
[6]
Charles R. Harris, K. Jarrod Millman, Stéfan J. van der Walt, Ralf Gommers, Pauli Virtanen, David Cournapeau, Eric Wieser, Julian Taylor, Sebastian Berg, Nathaniel J. Smith, Robert Kern, Matti Picus, Stephan Hoyer, Marten H. van Kerkwijk, Matthew Brett, Allan Haldane, Jaime Fernández del Río, Mark Wiebe, Pearu Peterson, Pierre Gérard-Marchant, Kevin Sheppard, Tyler Reddy, Warren Weckesser, Hameer Abbasi, Christoph Gohlke, and Travis E. Oliphant. 2020. Array programming with NumPy. Nature 585, 7825 (Sept. 2020), 357--362.
[7]
José J. Merchante and Gregorio Robles. 2017. From Python to Pythonic: Searching for Python idioms in GitHub. In Seminar Series on Advanced Techniques and Tools for Software Evolution (SATToSE).
[8]
Dmitry Orlov. 2020. Finding Idioms in Source Code Using Subtree Counting Techniques. In Leveraging Applications of Formal Methods, Verification and Validation: Engineering Principles. 44--54.
[9]
Tim Peters. 2004. PEP 20 - The Zen of Python | Python.org. https://www.python.org/dev/peps/pep-0020/. (Accessed on 11/16/2021).
[10]
Purit Phan-udom, Naruedon Wattanakul, Tattiya Sakulniwat, Chaiyong Ragkhitwetsagul, Thanwadee Sunetnanta, Morakot Choetkiertikul, and Raula Gaikovina Kula. 2020. Teddy: Automatic Recommendation of Pythonic Idiom Usage For Pull-Based Software Projects. In IEEE International Conference on Software Maintenance and Evolution (ICSME).
[11]
Luigi Quaranta, Fabio Calefato, and Filippo Lanubile. 2021. KGTorrent: A Dataset of Python Jupyter Notebooks from Kaggle.
[12]
Amanda Ross and Victor L. Willson. 2017. Independent Samples T-Test. SensePublishers, Rotterdam, 13--16.
[13]
Tattiya Sakulniwat, Raula Gaikovina Kula, Chaiyong Ragkhitwetsagul, Morakot Choetkiertikul, Thanwadee Sunetnanta, Dong Wang, Takashi Ishio, and Kenichi Matsumoto. 2019. Visualizing the Usage of Pythonic Idioms Over Time: A Case Study of the with open Idiom. In International Workshop on Empirical Software Engineering in Practice (IWE-SEP).
[14]
Pauli Virtanen, Ralf Gommers, Travis E. Oliphant, Matt Haberland, Tyler Reddy, David Cournapeau, Evgeni Burovski, Pearu Peterson, Warren Weckesser, Jonathan Bright, Stéfan J. van der Walt, Matthew Brett, Joshua Wilson, K. Jarrod Millman, Nikolay Mayorov, Andrew R.J. Nelson, Eric Jones, Robert Kern, Eric Larson, C J Carey, İlhan Polat, Yu Feng, Eric W. Moore, Jake VanderPlas, Denis Laxalde, Josef Perktold, Robert Cimrman, Ian Henriksen, E. A. Quintero, Charles R. Harris, Anne M. Archibald, Antônio H. Ribeiro, Fabian Pedregosa, Paul van Mulbregt, and SciPy 1.0 Contributors. 2020. SciPy 1.0: Fundamental Algorithms for Scientific Computing in Python. Nature Methods 17 (2020), 261--272.

Cited By

View all
  • (2024)The Limits of the Identifiable: Challenges in Python Version Identification with Deep Learning2024 IEEE International Conference on Software Analysis, Evolution and Reengineering (SANER)10.1109/SANER60148.2024.00022(137-146)Online publication date: 12-Mar-2024
  • (2023)Do Developers Present Proficient Code Snippets in Their README Files? An Analysis of PyPI Libraries in GitHubJournal of Information Processing10.2197/ipsjjip.31.67931(679-688)Online publication date: 2023
  • (2022)Visualizing Contributor Code Competency for PyPI Libraries: Preliminary Results2022 29th Asia-Pacific Software Engineering Conference (APSEC)10.1109/APSEC57359.2022.00065(472-476)Online publication date: Dec-2022

Recommendations

Comments

Please enable JavaScript to view thecomments powered by Disqus.

Information & Contributors

Information

Published In

cover image ACM Conferences
ICPC '22: Proceedings of the 30th IEEE/ACM International Conference on Program Comprehension
May 2022
698 pages
ISBN:9781450392983
DOI:10.1145/3524610
  • Conference Chairs:
  • Ayushi Rastogi,
  • Rosalia Tufano,
  • General Chair:
  • Gabriele Bavota,
  • Program Chairs:
  • Venera Arnaoudova,
  • Sonia Haiduc
Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than ACM must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected]

Sponsors

In-Cooperation

  • IEEE CS

Publisher

Association for Computing Machinery

New York, NY, United States

Publication History

Published: 20 October 2022

Permissions

Request permissions for this article.

Check for updates

Author Tags

  1. idioms
  2. performance
  3. python
  4. pythonic

Qualifiers

  • Short-paper

Funding Sources

Conference

ICPC '22
Sponsor:

Upcoming Conference

ICSE 2025

Contributors

Other Metrics

Bibliometrics & Citations

Bibliometrics

Article Metrics

  • Downloads (Last 12 months)35
  • Downloads (Last 6 weeks)3
Reflects downloads up to 12 Nov 2024

Other Metrics

Citations

Cited By

View all
  • (2024)The Limits of the Identifiable: Challenges in Python Version Identification with Deep Learning2024 IEEE International Conference on Software Analysis, Evolution and Reengineering (SANER)10.1109/SANER60148.2024.00022(137-146)Online publication date: 12-Mar-2024
  • (2023)Do Developers Present Proficient Code Snippets in Their README Files? An Analysis of PyPI Libraries in GitHubJournal of Information Processing10.2197/ipsjjip.31.67931(679-688)Online publication date: 2023
  • (2022)Visualizing Contributor Code Competency for PyPI Libraries: Preliminary Results2022 29th Asia-Pacific Software Engineering Conference (APSEC)10.1109/APSEC57359.2022.00065(472-476)Online publication date: Dec-2022

View Options

Get Access

Login options

View options

PDF

View or Download as a PDF file.

PDF

eReader

View online with eReader.

eReader

Media

Figures

Other

Tables

Share

Share

Share this Publication link

Share on social media