PyTrim: A Practical Tool for Reducing Python Dependency Bloat

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

Authors

Institutions

Publication Details

Published
2025-11-16
DOI
https://doi.org/10.1109/ase63991.2025.00377
Primary Topic
Computational Physics and Python Applications
Type
article
Field-Weighted Citation Impact
0.00
Controls
|||
ALL TIME
JAN
FEB
MAR
APR
MAY
JUN
JUL
AUG
SEP
OCT
article

PyTrim: A Practical Tool for Reducing Python Dependency Bloat

Dimitris Mitropoulos, Georgios Alexopoulos, Πάνος Λουρίδας, Konstantinos Karakatsanis et al.
Computational Physics and Python Applications
article

PyTrim: A Practical Tool for Reducing Python Dependency Bloat

Dimitris Mitropoulos, Georgios Alexopoulos, Πάνος Λουρίδας, Konstantinos Karakatsanis, Ioannis Karyotakis, Foivos Timotheos Proestakis, Evangelos Talos
article en

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

National and Kapodistrian University of Athens (GR), Athens University of Economics and Business (GR)
Openalex Percentile: Top 86%
Computational Physics and Python Applications
AI Navigator

Ask Laika to Summarize, Analyze, and Connect papers live on the map.

Summarize Papers & Methodologies

Extract key findings, datasets, and comparative methods across publications.

Benchmark Rankings & Visual Analytics

Rank top research institutions, authors, funders, topics, and journals by Field-Weighted Citation Impact (FWCI) and paper volume with instant charts.

Connect Distant Disciplines

Bridge topological clusters on the map to find hidden collaborative intersections.