Skip to main content

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 scan by default
  • Disable with --no-cache
  • Read by top

Troubleshooting

  • Cache not found: run coldpy 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 validate sdist + wheel.
  • publish.yml: publish on GitHub Release (PyPI) or manual dispatch (TestPyPI/PyPI).

Recommended publishing model is Trusted Publisher (OIDC):

  1. Create a PyPI project for coldpy (and optionally a TestPyPI project).
  2. In PyPI project settings, add your GitHub repo as a trusted publisher.
  3. Create a GitHub Release to publish to PyPI.
  4. Use workflow dispatch with target=testpypi for 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


Download files

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

Source Distribution

coldpy-0.1.0.tar.gz (49.4 kB view details)

Uploaded Source

Built Distribution

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

coldpy-0.1.0-py3-none-any.whl (12.3 kB view details)

Uploaded Python 3

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

Hashes for coldpy-0.1.0.tar.gz
Algorithm Hash digest
SHA256 2366254871bdd0b86cdd56ce70a65c91a5d63884cdc22da4108bceb2ef1b9b54
MD5 c9c34a2a4b804404cedd48df2b64086e
BLAKE2b-256 8886fc5b39341311d0cdbc30b3433d63b64e8e774915252c233a47fb8a5a6e1b

See more details on using hashes here.

Provenance

The following attestation bundles were made for coldpy-0.1.0.tar.gz:

Publisher: publish.yml on Eaglemann/ColdPy

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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

Hashes for coldpy-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 86b166c46c65965c3dc1fac5a4f605945b83f6c83edf2eba52eb10f1e145aff3
MD5 7d6333527043d1c3786afa0de0777214
BLAKE2b-256 dc9bc5795ef57424cd2b352591a9a08442c214162c267830f666014a7727b828

See more details on using hashes here.

Provenance

The following attestation bundles were made for coldpy-0.1.0-py3-none-any.whl:

Publisher: publish.yml on Eaglemann/ColdPy

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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