Skip to content

Replace sortedcontainers with builtin collections#8020

Merged
pavoljuhas merged 7 commits intoquantumlib:mainfrom
pavoljuhas:disuse-sortedcontainers
Apr 8, 2026
Merged

Replace sortedcontainers with builtin collections#8020
pavoljuhas merged 7 commits intoquantumlib:mainfrom
pavoljuhas:disuse-sortedcontainers

Conversation

@pavoljuhas
Copy link
Copy Markdown
Collaborator

@pavoljuhas pavoljuhas commented Apr 8, 2026

Eliminate unnecessary dependency on the sortedcontainers package.
Used in only one module where SortedSet could be ordered just once
after collection and where SortedDict could be also sorted later.

The median timeit timing of the affected get_initial_mapping calls
from unit test improved by about 20%.

@github-actions github-actions bot added the size: S 10< lines changed <50 label Apr 8, 2026
@pavoljuhas
Copy link
Copy Markdown
Collaborator Author

To check how performance changes with SortedSet replacement, here are timeit durations from initialization_test.py collected using

pytest -s --randomly-seed=99 --randomly-dont-reorganize --pyargs \
    cirq.contrib.routing.initialization_test

and plotted as a histogram of durations before and after this PR:

f

@pavoljuhas pavoljuhas marked this pull request as ready for review April 8, 2026 06:27
@pavoljuhas pavoljuhas requested review from a team and vtomole as code owners April 8, 2026 06:27
@pavoljuhas pavoljuhas requested a review from verult April 8, 2026 06:27
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 8, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.63%. Comparing base (3175c9d) to head (db7fc69).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #8020      +/-   ##
==========================================
- Coverage   99.63%   99.63%   -0.01%     
==========================================
  Files        1110     1110              
  Lines       99755    99755              
==========================================
- Hits        99394    99392       -2     
- Misses        361      363       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@pavoljuhas pavoljuhas marked this pull request as draft April 8, 2026 07:08
For routing reproducibility the best_candidates extracted from
dictionary keys need to be sorted as before with SortedDict.
@pavoljuhas pavoljuhas marked this pull request as ready for review April 8, 2026 17:50
@pavoljuhas pavoljuhas requested a review from mhucka April 8, 2026 17:50
Copy link
Copy Markdown
Contributor

@mhucka mhucka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice.

@pavoljuhas pavoljuhas added this pull request to the merge queue Apr 8, 2026
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Apr 8, 2026
@pavoljuhas pavoljuhas added this pull request to the merge queue Apr 8, 2026
Merged via the queue into quantumlib:main with commit 5b3eb0b Apr 8, 2026
73 of 77 checks passed
@pavoljuhas pavoljuhas deleted the disuse-sortedcontainers branch April 8, 2026 18:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size: S 10< lines changed <50

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants