Commit 8d5a3af
authored
Improve GridQubit dictionary lookup performance 3x (#3375)
According to the following profiling code, this change decreases the dictionary lookup time from 2100ns to 600ns on my machine.
```
import time
import cirq
d = {q: 5 for q in cirq.GridQubit.rect(3, 3)}
q = cirq.GridQubit(0, 0)
total = 0
t0 = time.monotonic()
n = 100000
for _ in range(n):
total += d[q]
t1 = time.monotonic()
print(total)
print((t1 - t0) / n * 10**9, "nanoseconds per hash")
```1 parent 8802685 commit 8d5a3af
1 file changed
+20
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
275 | 275 | | |
276 | 276 | | |
277 | 277 | | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
278 | 298 | | |
279 | 299 | | |
280 | 300 | | |
| |||
0 commit comments