Metadata-Version: 2.4
Name: philiprehberger-import-profiler
Version: 0.1.3
Summary: Show how long each Python import takes during startup
Project-URL: Homepage, https://github.com/philiprehberger/py-import-profiler#readme
Project-URL: Repository, https://github.com/philiprehberger/py-import-profiler
Project-URL: Issues, https://github.com/philiprehberger/py-import-profiler/issues
Project-URL: Changelog, https://github.com/philiprehberger/py-import-profiler/blob/main/CHANGELOG.md
Author: Philip Rehberger
License-Expression: MIT
License-File: LICENSE
Keywords: import,performance,profiler,startup,timing
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Typing :: Typed
Requires-Python: >=3.10
Description-Content-Type: text/markdown

# philiprehberger-import-profiler

[![Tests](https://github.com/philiprehberger/py-import-profiler/actions/workflows/publish.yml/badge.svg)](https://github.com/philiprehberger/py-import-profiler/actions/workflows/publish.yml)
[![PyPI version](https://img.shields.io/pypi/v/philiprehberger-import-profiler.svg)](https://pypi.org/project/philiprehberger-import-profiler/)
[![License](https://img.shields.io/github/license/philiprehberger/py-import-profiler)](LICENSE)

Show how long each Python import takes during startup.

## Installation

```bash
pip install philiprehberger-import-profiler
```

## Usage

```python
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

- `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

## License

MIT
