Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[8.2.x] fixtures: fix catastrophic performance problem in reorder_items #12414

Merged
merged 1 commit into from
Jun 4, 2024

Commits on Jun 4, 2024

  1. [8.2.x] fixtures: fix catastrophic performance problem in `reorder_it…

    …ems`
    
    Manual minimal backport from commit e89d23b.
    
    Fix pytest-dev#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.
    bluetech committed Jun 4, 2024
    Configuration menu
    Copy the full SHA
    153a436 View commit details
    Browse the repository at this point in the history