In cooperation with our research partners in academia, we offered a bachelor thesis in the field of program analysis at Heinrich-Heine-University Düsseldorf.
The recently finished thesis of a Bachelor student who was supervised by Axivion investigated static analysis of Python programs by creating a program dependency graph. Features like “late bound everything”, “monkey patching”, missing entry points or the fact that “everything is a mutable object” pose a challenge in static modelling of dependencies and make it hard or impossible to create an exact dependency graph.
Anyway, a useful approximation of the program structure of Python code can still be easily achieved if we make the assumption that runtime modification of the code is possible but not the first thing programmer’s think about when coding. With this assumption in mind, a full analysis of Python projects was build based on Python’s AST module and Axivion Suite’s API and GUI in less than three months.
The fun part of this thesis was the iterative and incremental approach allowing visual feedback to the student by using Axivion’s extensible GUI. As soon as the implementation of the first bits of the parser were ready, the results could be visualized and inspected. And by implementing the static analysis itself in Python, continuous self-application was possible… “if it is worth doing it, do it to itself”.The performance of the basic analysis steps was surprisingly good. Even though it is an interpreted language, it takes just minutes to analyze the entire Python Standard Libraries. First impressions on the software erosion aspects show that architecture analysis, dead code, or cycle detections in Python programs were successful and also give insights to Python programmers.
We are looking forward to evaluating and extending the prototype and analysing Python code in the future.
And of course – looking forward to the future thesis’ results.
[by Dr. Daniel Simon, Head of Professional Services, Axivion GmbH]