This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author giampaolo.rodola
Recipients giampaolo.rodola, rhettinger, stutzbach
Date 2011-11-22.01:03:41
SpamBayes Score 3.1731538e-06
Marked as misclassified No
Message-id <1321923822.73.0.49972384361.issue13451@psf.upfronthosting.co.za>
In-reply-to
Content
<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.
History
Date User Action Args
2011-11-22 01:03:42giampaolo.rodolasetrecipients: + giampaolo.rodola, rhettinger, stutzbach
2011-11-22 01:03:42giampaolo.rodolasetmessageid: <1321923822.73.0.49972384361.issue13451@psf.upfronthosting.co.za>
2011-11-22 01:03:42giampaolo.rodolalinkissue13451 messages
2011-11-22 01:03:41giampaolo.rodolacreate