Closed DanGonite57 closed 6 months ago
All modified and coverable lines are covered by tests :white_check_mark:
Project coverage is 100.00%. Comparing base (
b0c2952
) to head (c296570
).
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
Comparing DanGonite57:perf-clear
(c296570) with main
(b0c2952)
⚡ 1
improvements
✅ 65
untouched benchmarks
Benchmark | main |
DanGonite57:perf-clear |
Change | |
---|---|---|---|---|
⚡ | test_emit_time[lambda-2] |
127.8 µs | 114.3 µs | +11.78% |
wow. thanks this is fantastic. LGTM
Sorry about the weird BAIL
stuff... had to remind myself why it's there (clearly not obvious), I think it was mostly there for things like add
where subclasses might want the ability to cancel the event, or to avoid an event entirely as you've done in the case if len(self) == 0
. but your PR is perfect, thanks!
btw, the codspeed benchmarks shown above don't capture this, but the asv benchmarks do and are awesome 🤩
Change | Before [b0c29526] | After [3b7af9d8] | Ratio | Benchmark (Parameter) |
---|---|---|---|---|
- | 1.15±0.01μs | 689±7ns | 0.6 | benchmarks.EventedSetWithCallbackSuite.time_clear(10) |
- | 1.16±0.03μs | 682±2ns | 0.59 | benchmarks.EventedSetSuite.time_clear(10) |
- | 4.83±0s | 763±2ns | 0 | benchmarks.EventedSetSuite.time_clear(100000) |
- | 4.84±0.02s | 794±7ns | 0 | benchmarks.EventedSetWithCallbackSuite.time_clear(100000) |
"infinite speedup" :joy:
Motivated by https://github.com/napari/napari/issues/6746, https://github.com/napari/napari/pull/6895
The default
clear
method implemented bycollections.abc.MutableSet
is very slow, which I guess is due to the fact that it is not backed by the C implementation of the builtinset
.I have attempted to implement a custom interface for
clear
, modelled on the existing one fordiscard
. However, I don't entirely understand the intentions for the various hooks, BAILs, etc, so please do let me know if anything is inconsistent with the behaviours and styles of other methods.bench.py
Before:
After: