[plum] Tutorial: Packing StructuresΒΆ

To improve code readability, avoid creating a custom Structure subclass where it makes sense. Doing so simplifies your code, saves memory (each Python type consumes a few hundered bytes), and reduces import times. Instead, use a dictionary format and keyword arguments to pass values to the pack() utility. For example:

>>> from plum import pack
>>> from plum.int.little import UInt8
>>> # this is cryptic
>>> fmt = (UInt8, UInt8)
>>> pack(fmt, 12, 25)
>>> # this self-documents
>>> fmt = {'month': UInt8, 'day': UInt8}
>>> pack(fmt, month=12, day=25)