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.2.tar.gz (30.3 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.2-py3-none-any.whl (35.1 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for ltrim-0.1.2.tar.gz
Algorithm Hash digest
SHA256 98d429893a419b0392bcbf488aadf9d828815a60a48c1f2765bf7ee7cb91cb1f
MD5 e8ad9dd697a672a5f0b49244c284486b
BLAKE2b-256 0ab055ffa02c3775f87298b6e22d823e2fd47791f55e927ecc263c32fdea7a0d

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for ltrim-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 c2392d147757d8aef882b1f1e9140d3e563555e9085906c528302057b51ec917
MD5 114be67ad8fe2dcd5e9e1e7e0f1db67e
BLAKE2b-256 1999e94a4abb1fbbd9565d12be5c02f3aaf587c54769a42e5036cc5f76bc8b55

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