Skip to content

Micro-optimization: replace list lookup with set membership#1046

Merged
mhucka merged 3 commits intoquantumlib:mainfrom
mhucka:use-set-not-list
Apr 13, 2026
Merged

Micro-optimization: replace list lookup with set membership#1046
mhucka merged 3 commits intoquantumlib:mainfrom
mhucka:use-set-not-list

Conversation

@mhucka
Copy link
Copy Markdown
Collaborator

@mhucka mhucka commented Apr 12, 2026

In qsimcirq/qsim_circuit.py, changing the list GATE_PARAMS to a set will result in O(1) lookups. Not likely to make a big difference for the small set size, but perhaps it might shave some time off when many simulations are executed.

@github-actions github-actions Bot added the size: XS <10 lines changed label Apr 12, 2026
@mhucka mhucka marked this pull request as ready for review April 12, 2026 04:46
@mhucka mhucka requested a review from sergeisakov April 12, 2026 04:46
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request updates the GATE_PARAMS constant in qsimcirq/qsim_circuit.py from a list to a set. The reviewer pointed out that the accompanying comment still describes the variable as a 'List', which is now inaccurate, and recommended adding a type annotation to align with the project's style guide.

Comment thread qsimcirq/qsim_circuit.py
Copy link
Copy Markdown
Collaborator

@sergeisakov sergeisakov left a comment

Choose a reason for hiding this comment

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

LGTM

@mhucka mhucka added this pull request to the merge queue Apr 13, 2026
Merged via the queue into quantumlib:main with commit 046c8c9 Apr 13, 2026
29 checks passed
@mhucka mhucka deleted the use-set-not-list branch April 13, 2026 14:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size: XS <10 lines changed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants