Skip to content

Explore PyO3/Rust native resolution fast path #4

@danielstarman

Description

@danielstarman

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions