Learning paths

Different people come to DI for different reasons. This page suggests a reading order depending on what you need.

If you’re using FastAPI

  1. Quick start (FastAPI) (the full pattern in one page)

  2. FastAPI (integration details and testing guidance)

  3. Scopes & cleanup (what request scopes do and how cleanup works)

  4. Function injection (how Injected[T] is resolved)

If you’re new to DI (beginner)

  1. Dependency injection (DI) (what DI is and why teams use it)

  2. Why diwire (design goals and what makes diwire different)

  3. Quickstart (runnable tutorial starting from plain Python)

  4. Core concepts (the mental model behind registrations, scopes, and keys)

If you’ve used DI containers before (intermediate)

  1. Container (what gets resolved and how keys work)

  2. Registration (explicit bindings, factories, and instances)

  3. Scopes & cleanup and Lifetimes (caching and cleanup)

  4. How-to guides (frameworks and real-world patterns)

If you care about throughput (advanced)

  1. Compilation (what compile() does)

  2. Performance (benchmarks, methodology, and reproduction)

  3. Concurrency (lock modes and free-threaded considerations)

When you get stuck