An Empirical Study on Dynamic Typing Related Practices in Python Systems

Zhifei Chen, Yanhui Li, Bihuan Chen, Wanwangying Ma, Lin Chen, Baowen Xu
{"title":"An Empirical Study on Dynamic Typing Related Practices in Python Systems","authors":"Zhifei Chen, Yanhui Li, Bihuan Chen, Wanwangying Ma, Lin Chen, Baowen Xu","doi":"10.1145/3387904.3389253","DOIUrl":null,"url":null,"abstract":"The dynamic typing discipline of Python allows developers to program at a high level of abstraction. However, type related bugs are commonly encountered in Python systems due to the lack of type declaration and static type checking. Especially, the misuse of dynamic typing discipline produces underlying bugs and increases maintenance efforts. In this paper, we introduce six types of dynamic typing related practices in Python programs, which are the common but potentially risky usage of dynamic typing discipline by developers. We also implement a tool named PYDYPE to detect them. Based on this tool, we conduct an empirical study on nine real-world Python systems (with the size of more than 460KLOC) to understand dynamic typing related practices. We investigate how widespread the dynamic typing related practices are, why they are introduced into the systems, whether their usage correlates with increased likelihood of bug occurring, and how developers fix dynamic typing related bugs. The results show that: (1) dynamic typing related practices exist inconsistently in different systems and Inconsistent Variable Types is most prevalent; (2) they are introduced into systems mainly during early development phase to promote development efficiency; (3) they have a significant positive correlation with bug occurring; (4) developers tend to add type checks or exception handling to fix dynamic typing related bugs. These results benefit future research in coding convention, language design, bug detection and fixing.","PeriodicalId":231095,"journal":{"name":"2020 IEEE/ACM 28th International Conference on Program Comprehension (ICPC)","volume":"52 1","pages":"0"},"PeriodicalIF":0.0000,"publicationDate":"2020-07-13","publicationTypes":"Journal Article","fieldsOfStudy":null,"isOpenAccess":false,"openAccessPdf":"","citationCount":"14","resultStr":null,"platform":"Semanticscholar","paperid":null,"PeriodicalName":"2020 IEEE/ACM 28th International Conference on Program Comprehension (ICPC)","FirstCategoryId":"1085","ListUrlMain":"https://doi.org/10.1145/3387904.3389253","RegionNum":0,"RegionCategory":null,"ArticlePicture":[],"TitleCN":null,"AbstractTextCN":null,"PMCID":null,"EPubDate":"","PubModel":"","JCR":"","JCRName":"","Score":null,"Total":0}
引用次数: 14

Abstract

The dynamic typing discipline of Python allows developers to program at a high level of abstraction. However, type related bugs are commonly encountered in Python systems due to the lack of type declaration and static type checking. Especially, the misuse of dynamic typing discipline produces underlying bugs and increases maintenance efforts. In this paper, we introduce six types of dynamic typing related practices in Python programs, which are the common but potentially risky usage of dynamic typing discipline by developers. We also implement a tool named PYDYPE to detect them. Based on this tool, we conduct an empirical study on nine real-world Python systems (with the size of more than 460KLOC) to understand dynamic typing related practices. We investigate how widespread the dynamic typing related practices are, why they are introduced into the systems, whether their usage correlates with increased likelihood of bug occurring, and how developers fix dynamic typing related bugs. The results show that: (1) dynamic typing related practices exist inconsistently in different systems and Inconsistent Variable Types is most prevalent; (2) they are introduced into systems mainly during early development phase to promote development efficiency; (3) they have a significant positive correlation with bug occurring; (4) developers tend to add type checks or exception handling to fix dynamic typing related bugs. These results benefit future research in coding convention, language design, bug detection and fixing.
查看原文
分享 分享
微信好友 朋友圈 QQ好友 复制链接
本刊更多论文
Python系统中动态类型相关实践的实证研究
Python的动态类型原则允许开发人员在高层次的抽象上进行编程。然而,由于缺乏类型声明和静态类型检查,在Python系统中经常遇到与类型相关的错误。特别是,误用动态类型规则会产生潜在的错误并增加维护工作。在本文中,我们介绍了Python程序中与动态类型相关的六种类型的实践,这是开发人员对动态类型原则的常见但潜在风险的使用。我们还实现了一个名为pytype的工具来检测它们。基于这个工具,我们对9个真实的Python系统(规模大于460KLOC)进行了实证研究,以了解与动态类型相关的实践。我们研究了与动态类型相关的实践有多普遍,为什么将它们引入系统,它们的使用是否与错误发生的可能性增加相关,以及开发人员如何修复与动态类型相关的错误。结果表明:(1)不同系统中动态类型相关实践存在不一致性,其中变量类型不一致最为普遍;(2)主要在开发初期将其引入系统,以提高开发效率;(3)与虫患呈显著正相关;开发人员倾向于添加类型检查或异常处理来修复与动态类型相关的错误。这些结果对今后在编码规范、语言设计、bug检测和修复方面的研究有一定的帮助。
本文章由计算机程序翻译,如有差异,请以英文原文为准。
求助全文
约1分钟内获得全文 去求助
来源期刊
自引率
0.00%
发文量
0
期刊最新文献
On the Equivalence of Information Retrieval Methods for Automated Traceability Link Recovery: A Ten-Year Retrospective Program Comprehension in Virtual Reality How Does Incomplete Composite Refactoring Affect Internal Quality Attributes? A Literature Review of Automatic Traceability Links Recovery for Software Change Impact Analysis Inheritance software metrics on smart contracts
×
引用
GB/T 7714-2015
复制
MLA
复制
APA
复制
导出至
BibTeX EndNote RefMan NoteFirst NoteExpress
×
×
提示
您的信息不完整,为了账户安全,请先补充。
现在去补充
×
提示
您因"违规操作"
具体请查看互助需知
我知道了
×
提示
现在去查看 取消
×
提示
确定
0
微信
客服QQ
Book学术公众号 扫码关注我们
反馈
×
意见反馈
请填写您的意见或建议
请填写您的手机或邮箱
已复制链接
已复制链接
快去分享给好友吧!
我知道了
×
扫码分享
扫码分享
Book学术官方微信
Book学术官方微信
Book学术文献互助
Book学术文献互助群
群 号:604180095
Book学术
文献互助 智能选刊 最新文献 互助须知 联系我们:info@booksci.cn
Book学术提供免费学术资源搜索服务,方便国内外学者检索中英文文献。致力于提供最便捷和优质的服务体验。
Copyright © 2023 Book学术 All rights reserved.
ghs 京公网安备 11010802042870号 京ICP备2023020795号-1