zserio.compare module

The module implements ordering helpers used by the less than operator of the generated objects.

zserio.compare.compare(lhs: Any, rhs: Any) → int[source]

Compares two values.

A value which is not set (None) is less than a value which is set. Generated objects and arrays of the same type are compared by their three-way method _zserio_cmp, which visits each nested value only once. Other values are compared using only the less than operator.

Parameters:
  • lhs – Left hand side value.

  • rhs – Right hand side value.

Returns:

Negative number when lhs is less than rhs, positive number when rhs is less than lhs, else zero.