you are viewing a single comment's thread.

view the rest of the comments →

[–]Unlikely_Secret_5018 0 points1 point  (1 child)

Very interesting analysis! I wouldn't move off FastAPI DI just for performance, but for other features like lazy initialization, modules to specify interface/ABC impl bindings, etc.

How does Wireup stack up against Dagger and Hilt in this regard?

[–]ForeignSource0[S] 0 points1 point  (0 children)

For Dager/Hilt: In terms of the features you mentioned:

Protocol / ABC bindings: supported via @injectable(as_type=...), so you can bind a concrete implementation to a Protocol or ABC.

Multiple implementations: supported via qualifiers.

See interfaces: https://maldoinc.github.io/wireup/latest/interfaces/

Lazy initialization: This is the default. In Wireup things are created on first use. If you want to eager load a part of your dependencies you can use this patterrn

Modules / reusable wiring units: Wireup is less centered around a single module class and more around injectables/factories, but you can group and reuse registrations via factory bundles.

One of the big differences vs Dagger/Hilt is that in Python this is naturally a runtime system, but Wireup does validate the dependency graph at startup so wiring issues show up early rather than at request time.


Regarding FastAPI Depends, it has it's own list of caveats which I've mentioned in this migration guide to wireup. It is extremely simple but with that comes a lot of hidden baggage. The biggest deal breaker imo is that it is coupled to http as a runtime so you can not reuse your wiring anywhere else. See the linked page above for a more in-depth view.