Uppsats

Analysing Python Code at Scale for a Safe Thread-Concurrent Python

Master-uppsats

Uppsala universitet/Institutionen för informationsteknologi

Publicerad: 2025

Språk: Engelska

Sammanfattning

Python's popularity as a general-purpose programming language has led to its adoption across a wide array of domains, including web development, data science, and artificial intelligence. However, despite its versatility, Python faces significant performance limitations in CPU-bound tasks due to its Global Interpreter Lock (GIL), which restricts true multi-threaded parallelism. With the recent proposal for a GIL-free Python, there is a new effort to bring safe multi-threading with immutability to support race-free programming. This thesis intends to help these efforts by investigating how real-world Python functions interact with enclosing contexts and evaluates their compatibility with deep immutability as a strategy for thread safety. It presents a pipeline for collecting and analyzing Python projects from public repositories to quantify the prevalence of access patterns of enclosing contexts within the project's functions, as well as runtime modifications of said enclosing contexts. The results of the analyses demonstrate that the vast majority of functions from the gathered projects are compatible with trivial immutability, with 98% not showing signs of interaction with enclosing contexts.

Information

Lärosäte / institution
Uppsala universitet/Institutionen för informationsteknologi
Publiceringsdatum
2025
Uppsatstyp
Master-uppsats
Språk
Engelska