论文标题

Jupyter笔记本和脚本中Python代码的大规模比较

A Large-Scale Comparison of Python Code in Jupyter Notebooks and Scripts

论文作者

Grotov, Konstantin, Titov, Sergey, Sotnikov, Vladimir, Golubev, Yaroslav, Bryksin, Timofey

论文摘要

近年来,Jupyter笔记本在多个软件工程领域(例如数据科学,机器学习和计算机科学教育)中越来越受欢迎。它们的知名度与他们在呈现和可视化数据的丰富功能有关,但是,最近的研究表明,笔记本也有很多缺点:高度的代码克隆,低可重复性等等。 在这项工作中,我们进行了用Jupyter笔记本和传统Python脚本编写的Python代码之间的比较。我们从两个角度比较代码:结构和风格。在分析的第一部分中,我们报告了线数,函数使用情况以及各种复杂性指标的差异。在第二部分中,我们显示了风格问题数量的差异,并提供了研究媒介中15个最常见的风格问题的广泛概述。总体而言,我们证明笔记本的特征是较低的代码复杂性,但是,它们的代码比脚本中的代码更纠缠。至于样式,笔记本往往具有1.4倍的风格问题,但与此同时,其中一些是由笔记本中的特定编码实践引起的,应被视为误报。通过这项研究,我们想为研究笔记本的特定问题铺平道路,这些问题应通过开发笔记本特定的工具来解决,并提供各种在这方面有用的见解。

In recent years, Jupyter notebooks have grown in popularity in several domains of software engineering, such as data science, machine learning, and computer science education. Their popularity has to do with their rich features for presenting and visualizing data, however, recent studies show that notebooks also share a lot of drawbacks: high number of code clones, low reproducibility, etc. In this work, we carry out a comparison between Python code written in Jupyter Notebooks and in traditional Python scripts. We compare the code from two perspectives: structural and stylistic. In the first part of the analysis, we report the difference in the number of lines, the usage of functions, as well as various complexity metrics. In the second part, we show the difference in the number of stylistic issues and provide an extensive overview of the 15 most frequent stylistic issues in the studied mediums. Overall, we demonstrate that notebooks are characterized by the lower code complexity, however, their code could be perceived as more entangled than in the scripts. As for the style, notebooks tend to have 1.4 times more stylistic issues, but at the same time, some of them are caused by specific coding practices in notebooks and should be considered as false positives. With this research, we want to pave the way to studying specific problems of notebooks that should be addressed by the development of notebook-specific tools, and provide various insights that can be useful in this regard.

扫码加入交流群

加入微信交流群

微信交流群二维码

扫码加入学术交流群,获取更多资源