|
|
|
|
|
by carapace
2979 days ago
|
|
However... $ python -m timeit -s "a={k:k for k in range(10000)}" 'if 10001 in a:
b=a[10001]
else:
pass'
100000000 loops, best of 3: 0.0187 usec per loop
I gotta say, I didn't expect that. I thought the try..except.. for keys in the dict would be faster than this form. TIL |
|