The pure-Python resolution path is at ~2.24μs/op for a single-dep resolve after the fast positional optimization. To push under 1μs, the hot path (binding lookup, dependency graph traversal, factory invocation) would need to move to native code.
PyO3 + maturin could provide this: keep the Python API (container.bind(), container.resolve()) but implement the resolution internals in Rust. The Python layer would handle binding registration and type reflection, while Rust handles the cached resolution graph traversal and factory dispatch.
Rough expectations:
- Single-dep resolve: 0.1-0.3μs (down from 2.24μs)
- Deep chain: proportionally faster
- Async path: trickier due to Python coroutine boundary, may not benefit as much
This is exploratory — the current performance is already good enough for production use. This would be a "because we can" optimization.
The pure-Python resolution path is at ~2.24μs/op for a single-dep resolve after the fast positional optimization. To push under 1μs, the hot path (binding lookup, dependency graph traversal, factory invocation) would need to move to native code.
PyO3 + maturin could provide this: keep the Python API (
container.bind(),container.resolve()) but implement the resolution internals in Rust. The Python layer would handle binding registration and type reflection, while Rust handles the cached resolution graph traversal and factory dispatch.Rough expectations:
This is exploratory — the current performance is already good enough for production use. This would be a "because we can" optimization.