paperbot · PL 论文追踪

全部论文 待读 收藏

P2 An exploratory study on the predominant programming paradigms in Python code

Python 代码中主导编程范式的探索性研究
FSE Proceedings of the 30th ACM Joint European Software Engineering Conference and Symposium on the Foundations of Software Engineering2022匹配度 2/10 · 该论文是 Python 编程范式的经验性研究,虽涉及程序分析与 Python,但未涉及 LLM/Agent、浮点程序分析或贝叶斯程序分析,与用户画像的核心方向关联很弱。引用 6 inbox
Robert Dyer, Jigyasa Chauhan
crossref: 2026-09-12

AI 速览

一句话:提出自动化范式分类技术,并对十万余个开源 Python 项目进行分析,发现面向对象范式占据主导。

Python 是一种多范式语言,同时支持面向对象、过程式、命令式与函数式等编程风格,但此前尚不清楚实际 Python 代码与项目中究竟以哪些范式为主。本文首先提出一种将 Python 源文件划分到其主导范式的分类技术,并将其自动化实现;随后通过人工判断对该方法进行评估,两者一致率超过 80%。在此基础上,作者对超过 10 万个开源 Python 项目进行自动逐文件分类,并统计范式分布。结果显示,Python 开发者明显更偏好面向对象特性;面向对象与过程式范式的使用同项目规模呈正相关;尽管以函数式范式为主的文件或项目很少,但函数式特性的使用仍相当广泛。

问题
Python 支持多种编程范式,但社区尚不清楚实际代码与项目中哪些范式占主导,也缺少可自动识别文件的范式归属的手段。
方法
作者定义了一套将 Python 文件归类到主导范式的技术,并将其自动化,再与人工判断进行对比验证,最后对大规模开源项目逐文件分类并统计范式分布。
评估
通过人工判断验证分类器,一致率超过 80%;并在 10 万余个开源 Python 项目上开展大规模自动分析,考察范式分布及其与项目规模的关系。
原文摘要(Abstract)

Python is a multi-paradigm programming language that fully supports object-oriented (OO) programming. The language allows writing code in a non-procedural imperative manner, using procedures, using classes, or in a functional style. To date, no one has studied what paradigm(s), if any, are predominant in Python code and projects. In this work, we first define a technique to classify Python files into predominant paradigm(s). We then automate our approach and evaluate it against human judgements, showing over 80% agreement. We then analyze over 100k open-source Python projects, automatically classifying each source file and investigating the paradigm distributions. The results indicate Python developers tend to heavily favor OO features. We also observed a positive correlation between OO and procedural paradigms and the size of the project. And despite few files or projects being predominantly functional, we still found many functional feature uses.

链接与引用

DOI 原文 · PDF(开放获取) ·

BibTeX
@inproceedings{paperbot7076,
  title = {An exploratory study on the predominant programming paradigms in Python code},
  author = {Robert Dyer and Jigyasa Chauhan},
  booktitle = {FSE},
  year = {2022},
  doi = {10.1145/3540250.3549158}
}