zserio.bitbuffer module¶
The module implements abstraction for holding bit sequence.
- class zserio.bitbuffer.BitBuffer(buffer: bytes, bitsize: int | None = None)[source]¶
Bases:
object
Bit buffer.
Because bit buffer size does not have to be byte aligned (divisible by 8), it’s possible that not all bits of the last byte are used. In this case, only most significant bits of the corresponded size are used.
Constructs bit buffer from bytes buffer and bit size.
- Parameters:
buffer – Bytes-like buffer to construct from.
bitsize – Number of bits stored in buffer to use.
- Raises:
PythonRuntimeException – If bitsize is out of range.
- property bitsize: int¶
Gets the number of bits stored in the bit buffer.
- Returns:
Size of the bit buffer in bits.
- property buffer: bytes¶
Gets the underlying byte buffer.
Not all bits of the last byte must be used.
- Returns:
The underlying byte buffer.