Analyze Python startup import performance and memory usage
Project description
ColdPy
ColdPy profiles Python startup import cost by measuring import time and memory per module. It is built for serverless, microservices, and large Python apps where cold start matters.
What it measures
- Import duration (milliseconds)
- Import memory peak (MB) using
tracemalloc - Per-module status (success/error)
- Heavy module hints for lazy loading opportunities
Safety caveat
ColdPy measures real imports, so target module import code is executed in isolated subprocesses. This prevents state leakage between modules, but import side effects in target code may still occur.
Install
uv sync
Usage
coldpy scan
coldpy scan ./myproject
coldpy scan ./myproject --json report.json
coldpy scan ./myproject --exclude "migrations/**" --exclude "scripts/**"
coldpy top 10
coldpy top 20 --sort memory --threshold-mb 20
Commands
coldpy scan [PATH=. ] [--json OUTPUT_JSON] [--threshold-ms N] [--threshold-mb N] [--no-cache]coldpy scan PATH [--python PYTHON] [--env-file ENV_FILE] [--no-project-env] [--exclude PATTERN]coldpy top [N=10] [--sort time|memory] [--threshold-ms N] [--threshold-mb N]
coldpy top reads ./.coldpy/cache.json and fails if no cache exists.
For scan, ColdPy auto-detects project virtualenv Python in .venv, venv, or env
and auto-loads environment variables from .env/.env.local when present.
Use --python and --env-file only when you need to override auto-detection.
ColdPy also excludes common migration paths by default (alembic/**, migrations/**).
JSON schema (v1)
{
"schema_version": "1.0",
"generated_at": "2026-02-20T10:00:00+00:00",
"project_root": "/path/to/project",
"settings": {
"threshold_ms": 100,
"threshold_mb": 50,
"exclusions": ["tests", "venv"]
},
"summary": {
"total_modules": 3,
"scanned_modules": 2,
"failed_modules": 1
},
"modules": [
{
"name": "pkg.fast",
"file": "/path/to/project/pkg/fast.py",
"import_time_ms": 1.234,
"memory_mb": 0.123,
"status": "ok",
"error": null,
"notes": []
}
]
}
Cache behavior
- Cache path:
./.coldpy/cache.json - Written by
scanby default - Disable with
--no-cache - Read by
top
Troubleshooting
Cache not found: runcoldpy scan <path>first.No Python modules found: verify path and exclusions.- Import failures: check module side effects and importability from project root.
PyPI release setup
GitHub workflows are included in /Users/denis/Documents/ColdPy/.github/workflows:
ci.yml: test matrix on Python 3.10/3.11/3.12.package.yml: build and validatesdist+wheel.publish.yml: publish on GitHub Release (PyPI) or manual dispatch (TestPyPI/PyPI).
Recommended publishing model is Trusted Publisher (OIDC):
- Create a PyPI project for
coldpy(and optionally a TestPyPI project). - In PyPI project settings, add your GitHub repo as a trusted publisher.
- Create a GitHub Release to publish to PyPI.
- Use workflow dispatch with
target=testpypifor preflight package checks.
If you prefer API tokens instead of OIDC, set password input in the publish action
and store the token in GitHub Secrets.
Project details
Release history Release notifications | RSS feed
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 coldpy-0.1.0.tar.gz.
File metadata
- Download URL: coldpy-0.1.0.tar.gz
- Upload date:
- Size: 49.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2366254871bdd0b86cdd56ce70a65c91a5d63884cdc22da4108bceb2ef1b9b54
|
|
| MD5 |
c9c34a2a4b804404cedd48df2b64086e
|
|
| BLAKE2b-256 |
8886fc5b39341311d0cdbc30b3433d63b64e8e774915252c233a47fb8a5a6e1b
|
Provenance
The following attestation bundles were made for coldpy-0.1.0.tar.gz:
Publisher:
publish.yml on Eaglemann/ColdPy
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
coldpy-0.1.0.tar.gz -
Subject digest:
2366254871bdd0b86cdd56ce70a65c91a5d63884cdc22da4108bceb2ef1b9b54 - Sigstore transparency entry: 973323696
- Sigstore integration time:
-
Permalink:
Eaglemann/ColdPy@a50e7efa5342fb8119d30ae9f63e3e88d9fb0b4f -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/Eaglemann
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@a50e7efa5342fb8119d30ae9f63e3e88d9fb0b4f -
Trigger Event:
release
-
Statement type:
File details
Details for the file coldpy-0.1.0-py3-none-any.whl.
File metadata
- Download URL: coldpy-0.1.0-py3-none-any.whl
- Upload date:
- Size: 12.3 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 |
86b166c46c65965c3dc1fac5a4f605945b83f6c83edf2eba52eb10f1e145aff3
|
|
| MD5 |
7d6333527043d1c3786afa0de0777214
|
|
| BLAKE2b-256 |
dc9bc5795ef57424cd2b352591a9a08442c214162c267830f666014a7727b828
|
Provenance
The following attestation bundles were made for coldpy-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on Eaglemann/ColdPy
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
coldpy-0.1.0-py3-none-any.whl -
Subject digest:
86b166c46c65965c3dc1fac5a4f605945b83f6c83edf2eba52eb10f1e145aff3 - Sigstore transparency entry: 973323701
- Sigstore integration time:
-
Permalink:
Eaglemann/ColdPy@a50e7efa5342fb8119d30ae9f63e3e88d9fb0b4f -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/Eaglemann
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@a50e7efa5342fb8119d30ae9f63e3e88d9fb0b4f -
Trigger Event:
release
-
Statement type: