New submission from Giampaolo Rodola' <g.rod...@gmail.com>: <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. ---------- 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 <rep...@bugs.python.org> <http://bugs.python.org/issue13451> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com