A research team has built a framework that uses large language models to find and fix performance problems in Python code — no hand-written rules required.
FasterPy pairs retrieval-augmented generation with LoRA fine-tuning to steer an LLM toward efficient rewrites. The RAG component draws on a knowledge base of before-and-after code pairs tagged with measured performance improvements, so the model has concrete examples to work from rather than general coding intuitions. LoRA keeps the adaptation lightweight and relatively cheap to run. Tested against the Performance Improving Code Edits (PIE) benchmark — a standard dataset for this class of problem — FasterPy outperformed existing models across several metrics. Code and results are public on GitHub.
The case for this approach is straightforward: rule-based optimizers require engineers to manually catalogue every anti-pattern, and prior ML methods needed expensive annotated datasets tied to specific code representations. An LLM-based system can generalize more broadly and be updated without reengineering the pipeline. Whether those benchmark gains translate to messy real-world codebases is the question every paper like this leaves unanswered.
The timing matters: as LLM-assisted coding becomes routine, the natural next pressure point is runtime cost — writing code is getting easier, but slow code at scale is still expensive. FasterPy is academic research, not a shipping product, but it is pointed at a real problem that commercial tools have only partially solved.