Automated Refactoring of Non-Idiomatic Python Code: A Differentiated Replication with LLMs

Fuente: arXiv
Guardado en:
Detalles Bibliográficos
Autores principales: Midolo, Alessandro, Di Penta, Massimiliano
Formato: Preprint
Publicado: 2025
Materias:
Acceso en línea:
Etiquetas: Agregar Etiqueta
Sin Etiquetas, Sea el primero en etiquetar este registro!
_version_ 1866909468894167040
author Midolo, Alessandro
Di Penta, Massimiliano
author_facet Midolo, Alessandro
Di Penta, Massimiliano
contents In the Python ecosystem, the adoption of idiomatic constructs has been fostered because of their expressiveness, increasing productivity and even efficiency, despite controversial arguments concerning familiarity or understandability issues. Recent research contributions have proposed approaches -- based on static code analysis and transformation -- to automatically identify and enact refactoring opportunities of non-idiomatic code into idiomatic ones. Given the potential recently offered by Large Language Models (LLMs) for code-related tasks, in this paper, we present the results of a replication study in which we investigate GPT-4 effectiveness in recommending and suggesting idiomatic refactoring actions. Our results reveal that GPT-4 not only identifies idiomatic constructs effectively but frequently exceeds the benchmark in proposing refactoring actions where the existing baseline failed. A manual analysis of a random sample shows the correctness of the obtained recommendations. Our findings underscore the potential of LLMs to achieve tasks where, in the past, implementing recommenders based on complex code analyses was required.
format Preprint
id arxiv_https___arxiv_org_abs_2501_17024
institution arXiv
publishDate 2025
record_format arxiv
spellingShingle Automated Refactoring of Non-Idiomatic Python Code: A Differentiated Replication with LLMs
Midolo, Alessandro
Di Penta, Massimiliano
Software Engineering
In the Python ecosystem, the adoption of idiomatic constructs has been fostered because of their expressiveness, increasing productivity and even efficiency, despite controversial arguments concerning familiarity or understandability issues. Recent research contributions have proposed approaches -- based on static code analysis and transformation -- to automatically identify and enact refactoring opportunities of non-idiomatic code into idiomatic ones. Given the potential recently offered by Large Language Models (LLMs) for code-related tasks, in this paper, we present the results of a replication study in which we investigate GPT-4 effectiveness in recommending and suggesting idiomatic refactoring actions. Our results reveal that GPT-4 not only identifies idiomatic constructs effectively but frequently exceeds the benchmark in proposing refactoring actions where the existing baseline failed. A manual analysis of a random sample shows the correctness of the obtained recommendations. Our findings underscore the potential of LLMs to achieve tasks where, in the past, implementing recommenders based on complex code analyses was required.
title Automated Refactoring of Non-Idiomatic Python Code: A Differentiated Replication with LLMs
topic Software Engineering
url https://arxiv.org/abs/2501.17024