Message148103
<snippet>
# bench.py
import sched, time
events = []
scheduler = sched.scheduler(time.time, time.sleep)
for x in range(4000):
scheduler.enter(1, 1, lambda: None, ())
t = time.time()
for x in scheduler._queue:
scheduler.cancel(x)
print(time.time() - t)
</snippet>
Before the patch:
9.433167934417725
After the patch:
1.3120810985565186
I have another approach in mind, which avoids removing the element from the queue immediately, and which should be an order of magnitude faster, but I'll provide that as a separate patch since it poses questions about API and backward compatibility. |
|
Date |
User |
Action |
Args |
2011-11-22 01:03:42 | giampaolo.rodola | set | recipients:
+ giampaolo.rodola, rhettinger, stutzbach |
2011-11-22 01:03:42 | giampaolo.rodola | set | messageid: <1321923822.73.0.49972384361.issue13451@psf.upfronthosting.co.za> |
2011-11-22 01:03:42 | giampaolo.rodola | link | issue13451 messages |
2011-11-22 01:03:41 | giampaolo.rodola | create | |
|