Unambiguity of Python Language Elements for Static Analysis

Bence Nagy, Tibor Brunner, Zoltán Porkoláb · 2021

Static analysis is a technique for gathering some meaningful information during compilation-time and using it for further processing. This technique is applied in bug finding, code comprehension and in many other areas. However, static analysis gives a static view of the source and provides limited information about the dynamic behavior of a program. This limitation is generally considered to be a major barrier for dynamically typed languages, like Python, since in many situations it is hard to derive the most basic properties of variables or functions, sometimes we can’t even find the location of their definition. In this paper we present our experimental results that show this is not necessary a hard barrier in practical industrial projects. We analyzed open-source Python libraries, including the Python Standard Library itself as part of the CodeCompass code comprehension framework, and found that in a high number of the cases it was possible to decide the mentioned important features in unambiguous way. The consistent coding conventions make it possible to reduce unambiguity in static analysis of dynamic languages.

Read the paper · More papers on PaperTik