Python Package

Performance Optimization

Profiling and tuning Python code for speed and resource efficiency.

Early Access: Until 2026-12-31

For mgpy, performance only matters after correctness and signal quality are stable. Fast wrong reports are worse than slower correct ones.

Key points

  • CLI: On Windows the examples use the recommended py -3.12 -m <module> ... form (for example py -3.12 -m manifestguard ...). On Linux/macOS this usually maps to python3.12 -m ....
  • Measure where runtime is spent first: imports, dependency scans, report serialization or deeper analysis.
  • Optimizations should target real bottlenecks instead of guesses.
  • For CLI tools, stable response time matters more than flashy micro-benchmarks.

Recommended mgpy workflow

  1. Measure the baseline run and the extended run separately so expensive checks stay visible.
  2. Split heavy work into clearly named phases and enable it only when needed.
  3. Export the same mgpy report before and after performance work to ensure no capability was lost.

Quick start

py -3.12 -m manifestguard check --report .manifestguard/before.json
py -3.12 -m manifestguard check --extended --report .manifestguard/after.json
py -3.12 -m manifestguard export-metrics --output metrics.json