bpod_core.misc.ByteEnum

class bpod_core.misc.ByteEnum

Bases: IntEnum

An IntEnum whose values are single unsigned bytes.

Subclass this to define enums with byte-sized values. Each member caches its value as a bytes object for zero-allocation wire encoding.

Examples

>>> class Color(ByteEnum):
...     RED = 1
...     GREEN = 2
>>> Color.RED.as_bytes
b'\x01'
property as_bytes: bytes

The enum value as a single-byte bytes object.