Commit e89d23b
committed
fixtures: fix catastrophic performance problem in
Fix #12355.
In the issue, it was reported that the `reorder_items` has quadratic (or
worse...) behavior with certain simple parametrizations. After some
debugging I found that the problem happens because the "Fix
items_by_argkey order" loop keeps adding the same item to the deque,
and it reaches epic sizes which causes the slowdown.
I don't claim to understand how the `reorder_items` algorithm works, but
if as far as I understand, if an item already exists in the deque, the
correct thing to do is to move it to the front. Since a deque doesn't
have such an (efficient) operation, this switches to `OrderedDict` which
can efficiently append from both sides, deduplicate and move to front.reorder_items
1 parent 1eee63a commit e89d23b
File tree
3 files changed
+33
-7
lines changed- changelog
- src/_pytest
- testing/python
3 files changed
+33
-7
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| 28 | + | |
28 | 29 | | |
29 | 30 | | |
30 | 31 | | |
| |||
77 | 78 | | |
78 | 79 | | |
79 | 80 | | |
80 | | - | |
81 | | - | |
82 | 81 | | |
83 | 82 | | |
84 | 83 | | |
| |||
215 | 214 | | |
216 | 215 | | |
217 | 216 | | |
218 | | - | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
219 | 220 | | |
220 | 221 | | |
221 | | - | |
| 222 | + | |
222 | 223 | | |
223 | 224 | | |
224 | 225 | | |
225 | 226 | | |
226 | 227 | | |
227 | | - | |
| 228 | + | |
228 | 229 | | |
229 | 230 | | |
230 | 231 | | |
| |||
237 | 238 | | |
238 | 239 | | |
239 | 240 | | |
240 | | - | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
241 | 244 | | |
242 | 245 | | |
243 | 246 | | |
| |||
274 | 277 | | |
275 | 278 | | |
276 | 279 | | |
277 | | - | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
278 | 284 | | |
279 | 285 | | |
280 | 286 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2219 | 2219 | | |
2220 | 2220 | | |
2221 | 2221 | | |
| 2222 | + | |
| 2223 | + | |
| 2224 | + | |
| 2225 | + | |
| 2226 | + | |
| 2227 | + | |
| 2228 | + | |
| 2229 | + | |
| 2230 | + | |
| 2231 | + | |
| 2232 | + | |
| 2233 | + | |
| 2234 | + | |
| 2235 | + | |
| 2236 | + | |
| 2237 | + | |
| 2238 | + | |
| 2239 | + | |
| 2240 | + | |
2222 | 2241 | | |
2223 | 2242 | | |
2224 | 2243 | | |
| |||
0 commit comments