A dead-simple, zero-dependency lazy import proxy to make Python CLIs start instantly.
Project description
cli-speeder
Make your Python CLIs start instantly (10x-100x faster).
Python scripts are notoriously slow to start because they import heavy libraries (like pandas, torch, boto3, pydantic) at the top level, even if the user only runs a simple command like --help.
cli-speeder fixes this with zero code refactoring.
Installation
pip install cli-speeder
Usage
There are two ways to use this.
Method 1: The "One-Liner" (Recommended)
Add this once at the very top of your script (before your heavy imports).
from cli_speeder import speed_up_modules
# Magic: Forces these modules to load lazily
speed_up_modules(["pandas", "tensorflow", "boto3"])
# --- Your normal code stays exactly the same! ---
import pandas as pd \# 0ms (Instant)
import tensorflow as tf \# 0ms (Instant)
import boto3 \# 0ms (Instant)
def process_data():
\# The libraries only actually load HERE, when you use them.
df = pd.read_csv("data.csv")
Method 2: Manual Proxy (Granular Control)
If you want specific control over exactly which object is lazy.
from cli_speeder import lazy_import, lazy_from_import
# Replace 'import pandas as pd' with:
pd = lazy_import("pandas")
# Replace 'from pandas import DataFrame' with:
DataFrame = lazy_from_import("pandas", "DataFrame")
Benchmarks
Time to run python script.py --help:
| Library | Standard Import | With cli-speeder |
|---|---|---|
| Pandas | ~0.8s | < 0.01s |
| Torch | ~2.5s | < 0.01s |
| Boto3 | ~0.5s | < 0.01s |
Debugging / Production Safety
Lazy loading is great for CLIs, but sometimes (like in production workers) you might want standard behavior to catch ImportError immediately.
You can force all imports to happen immediately (disable lazy loading) by setting an environment variable:
export CLI_SPEEDER_EAGER=1
python my_script.py
License
cli_speeder is licensed under the Apache License 2.0. See the LICENSE file for more details.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file cli_speeder-0.1.3.tar.gz.
File metadata
- Download URL: cli_speeder-0.1.3.tar.gz
- Upload date:
- Size: 8.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b739aa3c0f0ec7c5fc4c040ffc9b676ffdebe89826c8519acad120a31abcbf64
|
|
| MD5 |
849f764465506839a553cb5cf08d5eca
|
|
| BLAKE2b-256 |
fcd07e5871dca1431285703ec89935cc371fbc7a820d442a5c6c47fcc945d3e8
|
Provenance
The following attestation bundles were made for cli_speeder-0.1.3.tar.gz:
Publisher:
publish.yml on Nabarup1/cli_speeder
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
cli_speeder-0.1.3.tar.gz -
Subject digest:
b739aa3c0f0ec7c5fc4c040ffc9b676ffdebe89826c8519acad120a31abcbf64 - Sigstore transparency entry: 731625946
- Sigstore integration time:
-
Permalink:
Nabarup1/cli_speeder@05d0c4366040675ec57318b2d55b35d9a65f077a -
Branch / Tag:
refs/tags/v0.1.3 - Owner: https://github.com/Nabarup1
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@05d0c4366040675ec57318b2d55b35d9a65f077a -
Trigger Event:
release
-
Statement type:
File details
Details for the file cli_speeder-0.1.3-py3-none-any.whl.
File metadata
- Download URL: cli_speeder-0.1.3-py3-none-any.whl
- Upload date:
- Size: 8.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6e0f7c5c8a0b577905f1f3088069d81e7f16fb36629ed26e511faa6824052f7e
|
|
| MD5 |
9ec37ae307110464d1e12f310305961c
|
|
| BLAKE2b-256 |
9bb02f0fdbe2c6c0304c7c920bfbf8cfed612bcd3f95c62f0ce38fe2f332191f
|
Provenance
The following attestation bundles were made for cli_speeder-0.1.3-py3-none-any.whl:
Publisher:
publish.yml on Nabarup1/cli_speeder
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
cli_speeder-0.1.3-py3-none-any.whl -
Subject digest:
6e0f7c5c8a0b577905f1f3088069d81e7f16fb36629ed26e511faa6824052f7e - Sigstore transparency entry: 731625949
- Sigstore integration time:
-
Permalink:
Nabarup1/cli_speeder@05d0c4366040675ec57318b2d55b35d9a65f077a -
Branch / Tag:
refs/tags/v0.1.3 - Owner: https://github.com/Nabarup1
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@05d0c4366040675ec57318b2d55b35d9a65f077a -
Trigger Event:
release
-
Statement type: