]> granicus.if.org Git - python/commitdiff
Issue 5830: Events are now comparable when the time and type are the same.
authorRaymond Hettinger <python@rcn.com>
Fri, 24 Apr 2009 18:43:43 +0000 (18:43 +0000)
committerRaymond Hettinger <python@rcn.com>
Fri, 24 Apr 2009 18:43:43 +0000 (18:43 +0000)
Lib/sched.py

index aecdb2a47554aa86599cb353a0aec610a902a2dc..11bb0a3a1861526d5e055e5f565529d86f804efe 100644 (file)
@@ -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):