Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ Every module under `modern_di/` is named for what it does; read it. What a singl
template per resolver shape and `exec`'d with the factory's constants as globals; the other provider
types compile to closures. A new provider type must add a branch here or `compile_resolver` raises.
Nothing in the template calls a helper on the hot path: the per-node frame budget is the point, and
`test_resolve_costs_exactly_one_resolver_frame_per_node` says why. Overrides are compiled in
(`docs/adr/0030-exec-template-resolver.md`): an override change drops the compiled resolvers.
`test_resolve_costs_exactly_one_resolver_frame_per_node` says why. Overrides are compiled in: an
override change drops the compiled resolvers.
- `exceptions.py` owns **every message and every glyph**. A raise site passes structured facts, never
formatting; the class renders its own f-string and sets a `docs_slug` (its page under
`docs/troubleshooting/`, enforced by `tests/test_docs_slug_census.py`). Add a message, a glyph, or a
Expand Down Expand Up @@ -79,5 +79,5 @@ a sibling test may be the one that trips.
- **Issues and specs** — GitHub Issues on `modern-python/modern-di`, via `gh`:
[`docs/agents/issue-tracker.md`](docs/agents/issue-tracker.md)
- **Triage labels** — the five canonical roles: [`docs/agents/triage-labels.md`](docs/agents/triage-labels.md)
- **Domain docs** — single-context, `CONTEXT.md` + `docs/adr/`: [`docs/agents/domain.md`](docs/agents/domain.md)
- **Domain docs** — single-context, `CONTEXT.md`; public choices on the design-decisions page, internal ones in `docs/adr/`: [`docs/agents/domain.md`](docs/agents/domain.md)
- **Cutting a release** (maintainers) — [`docs/agents/release.md`](docs/agents/release.md)
19 changes: 19 additions & 0 deletions docs/adr/0001-resolver-hot-path-generated-source.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# The resolve hot path is generated source, one frame per node

A `Factory` resolver is generated from a source template specialised to the factory's resolver
shape and `exec`'d with the factory's constants as its globals. Nothing on the hot path calls a
shared helper, and `test_resolve_costs_exactly_one_resolver_frame_per_node` enforces it. Every
all-Python single-copy design was measured first and lost 25-80% on a chain: folding the arity
ladder into one closure costs even for the branches not taken (closure size is paid on every call
on CPython 3.12+), and a shared `build()` or `call()` helper is a frame per node. So the
duplication the template removes cannot be removed with functions. Overrides are compiled in for
the same reason: an override change drops the compiled resolvers instead of every resolver
checking the overrides registry.

## Consequences

- The hot path is a string. `ruff`, `ty` and coverage do not see it; the shape-enumeration test
in `tests/test_resolver_compiler.py` is the gate for a template / namespace mismatch.
- One code object per shape, not per provider. Per provider is 20-30% faster on chains (call sites
stay monomorphic) but costs ~70 µs of `compile()` per provider, which a suite building a
container per test pays per test.
24 changes: 0 additions & 24 deletions docs/adr/0001-sync-async-close-separate.md

This file was deleted.

22 changes: 0 additions & 22 deletions docs/adr/0002-cache-arg-over-singleton-class.md

This file was deleted.

17 changes: 0 additions & 17 deletions docs/adr/0003-no-enter-scope-alias.md

This file was deleted.

18 changes: 0 additions & 18 deletions docs/adr/0004-no-generator-creators.md

This file was deleted.

26 changes: 0 additions & 26 deletions docs/adr/0005-no-multibinding.md

This file was deleted.

20 changes: 0 additions & 20 deletions docs/adr/0006-no-redirect-plugin.md

This file was deleted.

29 changes: 0 additions & 29 deletions docs/adr/0007-unify-graph-traversal.md

This file was deleted.

29 changes: 0 additions & 29 deletions docs/adr/0008-integration-kit-shape.md

This file was deleted.

23 changes: 0 additions & 23 deletions docs/adr/0009-error-text-is-not-a-contract.md

This file was deleted.

20 changes: 0 additions & 20 deletions docs/adr/0010-grpc-registry-introspection-declined.md

This file was deleted.

Loading
Loading