Antoine Pitrou added the comment: I don't think you need slicing if you rewrite the patch in another way, e.g.:
for i in range(n): try: waiter = __waiters.popleft() except IndexError: break waiter.release() I think this is safe, since notify() must be called with the lock held: another thread shouldn't be able to mutate the waiters list in the meantime. As for notify_all(), it could be optimized to swap the internal list with an empty one: there's no need to pop the waiters one by one. ---------- nosy: +neologix _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue17385> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com