arXivDaily arXiv每日学术速递 周一至周五更新
感恩节,周五至周末无更新,大家顺遂。周一再来吧
arXiv 2501.17024cs.SE
收藏

非地道Python代码的自动化重构:基于LLM的差异化复制研究

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

Alessandro Midolo, Massimiliano Di Penta

AI总结:

本文研究了GPT-4在推荐地道Python代码重构方面的有效性,发现其不仅能有效识别地道构造,还能在现有基线失败时提出正确的重构操作,突显了LLM替代复杂代码分析推荐器的潜力。

摘要:

在Python生态系统中,地道构造的采用因其表达能力、提升生产力和效率而受到促进,尽管存在关于熟悉度或可理解性问题的争议。最近的研究贡献提出了一些方法——基于静态代码分析和转换——来自动识别并实施将非地道代码重构为地道代码的机会。鉴于大型语言模型(LLM)近期在代码相关任务中展现的潜力,本文呈现了一项复制研究的结果,其中我们调查了GPT-4在推荐和提供地道重构操作方面的有效性。我们的结果显示,GPT-4不仅能有效识别地道构造,而且在提出重构操作方面经常超出基准,在现有基线失败的地方取得了成功。对随机样本的手动分析证明了所获得推荐的正确性。我们的发现突显了LLM在完成过去需要基于复杂代码分析的重构推荐器才能实现的任务方面的潜力。

英文摘要:

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.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑