-
Notifications
You must be signed in to change notification settings - Fork 23
Closed
Labels
enhancementNew feature or requestNew feature or request
Description
Desired change
- Rule(s): SIM105
- Adjustment: It should be dropped! Or at least highlight performance impact in the documentation!
Explanation
By conforming to this, the code will perform worse. Please check with timeit
.
In [1]: %%timeit
...: try:
...: a = {'a': 1}
...: a['b']
...: except KeyError:
...: pass
...:
199 ns ± 1.16 ns per loop (mean ± std. dev. of 7 runs, 1000000 loops each)
In [5]: %%timeit
...: with contextlib.suppress(KeyError):
...: a = {'a': 1}
...: a['b']
...:
621 ns ± 6.38 ns per loop (mean ± std. dev. of 7 runs, 1000000 loops each)
maxfischer2781MartinThoma and reactive-firewall
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request