Understand the serialization header format
masterWhen using serialize(), the first byte of the resulting bytes object is a header byte used to reconstruct the bitarray.
x[0] % 16: The number of pad bits (0..7) within the last byte.x[0] // 16: The bit-endianness (0 for little-endian, 1 for big-endian).
Valid header values are in the ranges 0 .. 7 or 16 .. 23. For an empty bitarray, the only valid header values are 0 or 16.