Bachelor Thesis BCLR-2025-08

BibliographyVezenkov, Aleksis: Performance-Improving Refactorings for Python.
University of Stuttgart, Faculty of Computer Science, Electrical Engineering, and Information Technology, Bachelor Thesis No. 8 (2025).
51 pages, english.
Abstract

Python is one of the most popular and versatile programming languages used by experienced and inexperience developers across diverse domains. However, Python often suffers from performance inefficiencies due to its dynamic nature. Improving the runtime efficiency of Python code typically requires manual, error-prone refactorings, and even then, validating their correctness and measuring their impact remains a challenge. This thesis presents OptiPy, a novel approach for discovering and validating performance-improving refactorings of Python functions. Given a single function, OptiPy synthesizes refactored versions using large language models. The approach integrates learningguided execution, performance benchmarking, and behavioral comparison into a unified pipeline. OptiPy ensures that candidate refactorings are executable and yield measurable performance improvements. Furthermore, OptiPy tests the semantic behavior of the refactorings against the source function. Our evaluation on two datasets, one based on open source functions and MBPP, show that OptiPy finds faster variants for 22% and 49% of the functions, respectively, with average performance gains of 30% and 44%. These results demonstrate the potential of combining LLMs and dynamic analysis for automated performance optimization.

Department(s)University of Stuttgart, Institute of Software Technology, Software Lab - Program Analysis
Superviser(s)Pradel, Prof. Michael; Souza, Beatriz
Entry dateJuly 9, 2025
   Publ. Institute   Publ. Computer Science