[New-bugs-announce] [issue13451] sched.py: speedup cancel() method

Giampaolo Rodola' report at bugs.python.org
Tue Nov 22 02:03:42 CET 2011

New submission from Giampaolo Rodola' <g.rodola at gmail.com>:

# 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:
print(time.time() - t)

Before the patch:

After the patch:

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.

files: sched-cancel-speedup.patch
keywords: patch
messages: 148103
nosy: giampaolo.rodola, rhettinger, stutzbach
priority: normal
severity: normal
status: open
title: sched.py: speedup cancel() method
versions: Python 3.3
Added file: http://bugs.python.org/file23750/sched-cancel-speedup.patch

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list