Skip to content

Commit 046c8c9

Browse files
authored
Micro-optimization: replace list lookup with set membership (#1046)
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.
1 parent 2533066 commit 046c8c9

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

qsimcirq/qsim_circuit.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919

2020
from . import qsim
2121

22-
# List of parameter names that appear in valid Cirq protos.
23-
GATE_PARAMS = [
22+
# Set of parameter names that appear in valid Cirq protos.
23+
GATE_PARAMS = {
2424
"exponent",
2525
"phase_exponent",
2626
"global_shift",
@@ -29,7 +29,7 @@
2929
"axis_phase_exponent",
3030
"phi",
3131
"theta",
32-
]
32+
}
3333

3434

3535
def _translate_ControlledGate(gate: cirq.ControlledGate):

0 commit comments

Comments
 (0)