Pythonic Zen中的编码是否达到性能峰值?九个Python习语的规模化初步实验
Does Coding in Pythonic Zen Peak Performance? Preliminary Experiments of Nine Pythonic Idioms at Scale
摘要:
在数据科学领域,对于一般的学者来说,Python程序设计语言是一种流行的选择,主要是因为它的库用于存储,操作和从数据中获得洞察力。证据包括用于不断增长的可用数据的多功能机器学习、数据可视化和操作包。Python的Zen是一组指导设计原则,开发人员使用这些原则来编写可接受的优雅Python代码。大多数原则都围绕着简单性。然而,由于需要计算大量的数据,性能已经成为Python程序员的必需品。本文的新想法是确认编写Python的方式是否会在规模上达到性能峰值。作为一个起点,我们进行了一组初步的实验,通过比较Pythonic和非Pythonic代码片段的性能来评估9个Pythonic代码示例。我们的研究结果表明,用Python习语写作可以节省内存和时间。我们展示了合并列表解析、生成器表达式、zip和itertools.zip_longest习惯用法可以节省高达7,000 MB和32.25秒。这些结果为如何在现实世界中使用它们提出了更多问题。复制包包括所有脚本,结果可在https://doi.org/10.5281/zenodo.5712349上获得
英文摘要:
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
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。