Skip to main content

Add your description here

Project description

λ-trim

λ-trim is a debloater for Python applications. Given a Python function and a set of inputs to this function λ-trim automatically removes all redundant modules, functions and classes from the modules that the application imports.

Installation

Install λ-trim from PyPI:

pip install ltrim

Usage

Basic Usage

To run the debloater against a Python script file.py, a testcase file with a specific structure is needed (see Test cases format from our accompanying benchmark repository).

debloat /path/to/code/file.py

By default, λ-trim assumes the existence of the testcases fike under the name data.json in the current working directory. You can also specify the path to this file with the -t, --testcases flag, like:

debloat /path/to/code/file.py -t /path/to/code/data.json

Scoring Methods

Users can specify the number of modules that they want to debloat by using the -k flag. Additionally, the ranking of the top K modules can be set by using the -s, --scoring flag. λ-trim currently supports the following scoring methods:

  • cost, which corresponds to the serverless cost models and takes into account both import time and memory footprint (default)
  • time, which ranks modules based on import time
  • memory, which ranks modules based on memory footprint
  • random, which ranks modules randomly.

Users can provide their own custom scoring functions by extending the scoring function in ltrim/debloat/utils.

Citation

Please use the following citation when reffering to the source code and/or the accompanying paper

@article{pavlatos2025lambdatrim,
  title={𝜆-trim: Reducing Monetary and Performance Cost of Serverless Cold Starts with Cost-driven Application Debloating},
  author={Liu, Xuting and Pavlatos, Spyros and Liu, Yuhao and Liu, Vincent},
  journal={UNDER SUBMISSION},
  year={2025}
}

License

This project is licensed under the GNU General Public License v3.0.

You are free to use, modify, and distribute this software under the terms of the GPL-3.0 License.

Copyright (C) 2025 University of Pennsylvania

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ltrim-0.1.0.tar.gz (30.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ltrim-0.1.0-py3-none-any.whl (34.7 kB view details)

Uploaded Python 3

File details

Details for the file ltrim-0.1.0.tar.gz.

File metadata

  • Download URL: ltrim-0.1.0.tar.gz
  • Upload date:
  • Size: 30.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.3

File hashes

Hashes for ltrim-0.1.0.tar.gz
Algorithm Hash digest
SHA256 20705bffe39278083536675d5c3fcd065329aa5bf594a341c10f5c398ae8496e
MD5 46a5273f99f152049734506d1402d11f
BLAKE2b-256 8ddab7a2e1def8e14c051686b8a2fde57653621c7a732020d24f3382a8fc7019

See more details on using hashes here.

File details

Details for the file ltrim-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: ltrim-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 34.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.3

File hashes

Hashes for ltrim-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 64356fbf339a1d87122590c7650623b82c1f918d079add04a401dba2b2728793
MD5 99bfea64c980c8db6e3ed2a8c4604d46
BLAKE2b-256 5a8f6319201e6b130965b72317d82318f58cf12fd51b18e09a72fca05e239291

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page