Show how long each Python import takes during startup
Project description
philiprehberger-import-profiler
Show how long each Python import takes during startup.
Installation
pip install philiprehberger-import-profiler
Usage
from philiprehberger_import_profiler import profile_imports
report = profile_imports("my_package")
# Slowest imports
for entry in report.slowest(10):
print(f"{entry.name}: {entry.duration_ms:.1f}ms")
# Tree view
report.print_tree(threshold_ms=5.0)
# └── my_package (124.5ms)
# ├── requests (45.2ms)
# │ └── urllib3 (22.1ms)
# └── numpy (62.0ms)
# Summary
print(f"Total: {report.total_ms:.1f}ms, Modules: {report.module_count}")
# Export
data = report.to_dict()
API
| Function / Class | Description |
|---|---|
profile_imports(module_name) |
Profile all imports, returns ImportReport |
report.slowest(n) |
Top N slowest imports |
report.print_tree(threshold_ms=0) |
Print indented tree |
report.total_ms |
Total import time |
report.to_dict() |
Export as list of dicts |
Development
pip install -e .
python -m pytest tests/ -v
License
MIT
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 philiprehberger_import_profiler-0.1.6.tar.gz.
File metadata
- Download URL: philiprehberger_import_profiler-0.1.6.tar.gz
- Upload date:
- Size: 4.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1d2965e27b585742875ceffee56ac0b5c76ae5366799bc788014c02afee220e6
|
|
| MD5 |
8a62e2319ec4a0a5bbb576b9738d20e2
|
|
| BLAKE2b-256 |
30ee6e538c46de11334bcec3c5b8c5dbcfb48a7a98172d78410fda2999532a50
|
File details
Details for the file philiprehberger_import_profiler-0.1.6-py3-none-any.whl.
File metadata
- Download URL: philiprehberger_import_profiler-0.1.6-py3-none-any.whl
- Upload date:
- Size: 4.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2a1fc183977ba83dab0d657175e33c752b884dbd17cfce84e67ae74b2836ba1c
|
|
| MD5 |
f1ee49329bf1f3ccce5787394af696d1
|
|
| BLAKE2b-256 |
df3bcd19cc18864200e4d13c55c5d357520482c79146b839ffabfc8378e6a4c3
|