<!-- HILSTER oser 3.3.0 -->
**OSER 3.3.0** · [HTML](../comparison.html) · [Complete PDF manual](../_downloads/oser-3.3.0.pdf)

<a id="rich-comparison"></a>

# Rich Comparison

[`oser.ByteStruct`](complextypes.md#oser.ByteStruct) and [`oser.BitStruct`](complextypes.md#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

```python
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
```
