Rich Comparison
oser.ByteStruct
and oser.BitStruct
offer full support
for rich comparisons.
Comparison is done by converting the members of both compared instances to lists and applying the compare operation on the lists. This leads to a hierarchical comparison in lexicographic order.
A comparison for == None
always returns False
and != None
always returns True
.
Example
class Struct(oser.ByteStruct):
def __init__(self):
super(Struct, self).__init__()
self.a = oser.UBInt8(1)
self.b = oser.UBInt16(2)
a = Struct()
b = Struct()
a == b
# True
b.b.set(3)
a != b
# True
a < b
# True
a <= b
# True
a.a.set(23)
a > b
# True
a >= b
# True