Publication
MSR 2022
Conference paper

Complex Python Features in the Wild

View publication

Abstract

While Python is increasingly popular, program analysis tooling for Python is lagging. This is due, in part, to complex features of the Python language-features with difficult to understand and model semantics. Besides the 'usual suspects', reflection and dynamic execution, complex Python features include context managers, decorators, and generators, among others. This paper explores how often and in what ways developers use certain complex features. We analyze over 3 million Python files mined from GitHub to address three research questions: (i) How often do developers use certain complex Python features? (ii) In what ways do developers use these features? (iii) Does use of complex features increase or decrease over time? Our findings show that usage of dynamic features that pose a threat to static analysis is infrequent. On the other hand, usage of context managers and decorators is surprisingly widespread. Our actionable result is a list of Python features that any 'minimal syntax' ought to handle in order to capture developers' use of the Python language. We hope that understanding the usage of Python features will help tool-builders improve Python tools, which can in turn lead to more correct, secure, and performant Python code.

Date

Publication

MSR 2022

Authors

Share