Commit af80fa5
committed
fixtures: remove dirty optimization for
Currently for each `Function` we copy the `FunctionDefinition`'s
`_arg2fixturedefs`. This is done due to an ineffective optimization for
a dynamic `request.getfixturevalue()` when the fixture name wasn't
statically requested. In this case, we would save the dynamically-found
`FixtureDef` in `_arg2fixturedef`, such that if it is requested again in
the same item, it is returned immediately instead of doing a
`_matchfactories` check again. But this case is already covered by the
`_fixture_defs` optimization.
I've always disliked this copy and mutation. The `_arg2fixturedefs`
shenanigans performed during collection are hard enough to follow, and
this only adds to the complexity, due to the mutability and having
multiple different `_arg2fixturedefs` with different contents.
So summing up:
Pros: faster repeated `request.getfixturevalue()` in same test (ineffective)
Cons: complexity (reasoning about mutability), extra copy
Even without the `_fixture_defs` optimization, since
`request.getfixturevalue()` is mostly a last-resort thing, so shouldn't
be too common, and *repeated* calls to it in the same test should be
even less common, and if so `_matchfactories` shouldn't be *that* slow,
it should be fine to remove it.request.getfixturevalue()
1 parent d889ca0 commit af80fa5
1 file changed
Lines changed: 5 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
363 | 363 | | |
364 | 364 | | |
365 | 365 | | |
366 | | - | |
| 366 | + | |
367 | 367 | | |
368 | 368 | | |
369 | 369 | | |
| |||
372 | 372 | | |
373 | 373 | | |
374 | 374 | | |
375 | | - | |
376 | | - | |
377 | | - | |
378 | | - | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
379 | 378 | | |
380 | 379 | | |
381 | 380 | | |
| |||
564 | 563 | | |
565 | 564 | | |
566 | 565 | | |
567 | | - | |
568 | | - | |
569 | 566 | | |
570 | 567 | | |
571 | 568 | | |
| |||
669 | 666 | | |
670 | 667 | | |
671 | 668 | | |
672 | | - | |
| 669 | + | |
673 | 670 | | |
674 | 671 | | |
675 | 672 | | |
| |||
0 commit comments