Ticket #23102: cmp-timing.py

File cmp-timing.py, 550 bytes (added by jdemeyer, 4 years ago)

Small script to test timing

Line 
1from functools import total_ordering
2from sage.structure.richcmp import richcmp_method, richcmp
3
4@total_ordering
5class A(object):
6    def __init__(self, value):
7        self.value = value
8    def __eq__(self, other):
9        return self.value == other.value
10    def __lt__(self, other):
11        return self.value < other.value
12
13@richcmp_method
14class B(object):
15    def __init__(self, value):
16        self.value = value
17    def __richcmp__(self, other, op):
18        return richcmp(self.value, other.value, op)
19
20A1 = A(1)
21A2 = A(2)
22B1 = B(1)
23B2 = B(2)