Use a Model
Example
# Set fields
coordinate = Coordinate()
coordinate.x.set(12.2)
coordinate.y.set(13.7)
bytes_ = coordinate.to_bytes()
#
# Send bytes "over the wire"
#
# Get fields
coordinate = Coordinate()
coordinate.from_bytes(bytes_)
x = coordinate.x.get()
y = coordinate.y.get()