diff options
author | Raymond Hettinger <python@rcn.com> | 2009-04-24 18:43:43 (GMT) |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2009-04-24 18:43:43 (GMT) |
commit | 8f40e099c39084f18be980ded5521603fe68800a (patch) | |
tree | e00bd26694315087c04678fc677d67333c8fe1d6 /Lib/sched.py | |
parent | 6ab91487c446bbc39047f7d43bbf02bf18c2645b (diff) | |
download | cpython-8f40e099c39084f18be980ded5521603fe68800a.zip cpython-8f40e099c39084f18be980ded5521603fe68800a.tar.gz cpython-8f40e099c39084f18be980ded5521603fe68800a.tar.bz2 |
Issue 5830: Events are now comparable when the time and type are the same.
Diffstat (limited to 'Lib/sched.py')
-rw-r--r-- | Lib/sched.py | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/Lib/sched.py b/Lib/sched.py index aecdb2a..11bb0a3 100644 --- a/Lib/sched.py +++ b/Lib/sched.py @@ -33,7 +33,13 @@ from collections import namedtuple __all__ = ["scheduler"] -Event = namedtuple('Event', 'time, priority, action, argument') +class Event(namedtuple('Event', 'time, priority, action, argument')): + def __eq__(s, o): return (s.time, s.priority) == (o.time, o.priority) + def __ne__(s, o): return (s.time, s.priority) != (o.time, o.priority) + def __lt__(s, o): return (s.time, s.priority) < (o.time, o.priority) + def __le__(s, o): return (s.time, s.priority) <= (o.time, o.priority) + def __gt__(s, o): return (s.time, s.priority) > (o.time, o.priority) + def __ge__(s, o): return (s.time, s.priority) >= (o.time, o.priority) class scheduler: def __init__(self, timefunc, delayfunc): |