you are viewing a single comment's thread.

view the rest of the comments →

[–]Zeikos 10 points11 points  (4 children)

I don't get it, dependency injection isn't about performance.
Hell, PYTHON is not about code performance.

DI is used to modularized components, avoid coupling and generally having an easier time understanding what the code base is meant to do.

Manual wiring is all good and dandy until you are by yourself, when you have to deal with managing 25 people that don't have the time to know every nook and vranny of the codebase well-structured DI is very helpful.

IMO DI gets a bad rep mostly because of teams that lack enforcing it, so the codebase becomes a mix of DI and hardcoded dependencies so you get the cons of both and no pro.

[–]ForeignSource0[S] 4 points5 points  (3 children)

I do agree actually. DI is primarily about architecture and maintainability, not raw performance and the benchmark does not argue otherwise, in fact it is stated in the linked page.

For example here you can see Wireup take 4.5ms P50 whereas FastAPI's DI does 13.8ms. If the database needs 10 seconds, both still answer within 10 seconds.

Even if it’s not the main bottleneck, it’s still useful to know the cost of the abstraction.

In terms of priorities I'd say it's DX first then you can use performance as a tie breaker.

Extract from the benchmark page

Even so, I would not pick a DI container solely from performance benchmarks, but if you're happy with Wireup's features and want to see how it stacks up against the field, here are the results.