paperbot · PL 论文追踪

全部论文 待读 收藏

P2 PyTrim: A Practical Tool for Reducing Python Dependency Bloat

PyTrim:一个减少 Python 依赖膨胀的实用工具
ASE 2025 40th IEEE/ACM International Conference on Automated Software Engineering (ASE)2025匹配度 2/10 · 该论文属于程序分析与开发者工具,关注 Python 未使用依赖的自动化清理,并引入动态分析提升召回率;但它不涉及 LLM/Agent、浮点程序分析、贝叶斯程序分析,也未与 ML 系统或形式化验证交叉,因此与用户核心研究方向匹配度低。引用 0 inbox
Konstantinos Karakatsanis, Georgios Alexopoulos, Ioannis Karyotakis, Foivos Timotheos Proestakis, Evangelos Talos, Panos Louridas, Dimitris Mitropoulos
crossref: 2026-09-12

AI 速览

一句话:PyTrim 是端到端自动化删除 Python 项目未使用依赖的工具,并引入动态分析提升检测召回率。

依赖膨胀是 Python 项目长期面临的难题,会提高维护成本并带来安全风险。现有工具大多只能检测未使用的依赖,而跨源码与配置文件的删除仍需人工完成。本文提出 PyTrim,一个端到端系统,自动删除 Python 源文件中的未使用 import 以及 requirements.txt、setup.py 等配置文件中的冗余包声明。其模块化设计使其与依赖膨胀信息来源解耦,可集成任意检测工具;同时内置新颖的动态分析组件以提高依赖检测的召回率。作者在来自先前工作的 37 个已合并 pull request 的真值数据集上评估,PyTrim 复现人工修改的准确率达 98.3%。在实际应用中,PyTrim 在 971 个开源包上运行,识别并清理了其中 39 个包的膨胀依赖,并为每个案例提交了 pull request,已有 14 个被接受合并。工具已开源。

问题
Python 项目普遍存在依赖膨胀,现有工具虽能检测未使用依赖,但跨源码与配置文件删除这些依赖仍需人工且依赖专业知识。
方法
PyTrim 采用模块化设计,与依赖检测工具解耦,自动删除 Python 源码中的未使用 import 和 requirements.txt、setup.py 等配置文件中的包声明,并集成动态分析组件提高检测召回率。
评估
在 37 个已合并 pull request 的真值数据集上,PyTrim 复现人工修改的准确率达 98.3%;在 971 个开源包上运行,识别并清理了 39 个包的依赖膨胀,提交的 pull request 中已有 14 个被接受合并。
原文摘要(Abstract)

Dependency bloat is a persistent challenge in Python projects, which increases maintenance costs and security risks. While numerous tools exist for detecting unused dependencies in Python, removing these dependencies across the source code and configuration files of a project requires manual effort and expertise. To tackle this challenge we introduce PYTRIM, an end-to-end system to automate this process. PYTRIM eliminates unused imports and package declarations across a variety of file types, including Python source and configuration files such as requirements.txt and setup.py. PYTRIM’s modular design makes it agnostic to the source of dependency bloat information, enabling integration with any detection tool. Beyond its contribution when it comes to automation, PYTRIM also incorporates a novel dynamic analysis component that improves dependency detection recall. Our evaluation of PYTRIM’s end-to-end effectiveness on a ground-truth dataset of 37 merged pull requests from prior work, shows that PYTRIM achieves 98.3% accuracy in replicating human-made changes. To show its practical impact, we run PYTRIM on 971 open-source packages, identifying and trimming bloated dependencies in 39 of them. For each case, we submit a corresponding pull request, 14 of which have already been accepted and merged. PYTRIM is available as an open-source project, encouraging community contributions and further development.Video demonstration: https://youtu.be/LqTEdOUbJRICode repository: https://github.com/TrimTeam/PyTrim

链接与引用

DOI 原文 · PDF(开放获取) ·

BibTeX
@inproceedings{paperbot9352,
  title = {PyTrim: A Practical Tool for Reducing Python Dependency Bloat},
  author = {Konstantinos Karakatsanis and Georgios Alexopoulos and Ioannis Karyotakis and Foivos Timotheos Proestakis and Evangelos Talos and Panos Louridas and Dimitris Mitropoulos},
  booktitle = {ASE},
  year = {2025},
  doi = {10.1109/ase63991.2025.00377}
}