struct packs primitive values into bytes and back. Import it by bare name, both runtimes resolve it with no manifest. To pin a different version, import it by URL or through a packages.json alias, see Modules.
Functions are pack(fmt, *values), unpack(fmt, data), and calcsize(fmt). Codes are x b B ? h H i I q Q f d with repeat counts, and byte-order prefixes are < (the default), =, >, !. There is no native-alignment mode. unpack returns a list. A packed buffer crosses the host boundary once, which makes it the fast lane for bulk numeric data. Out-of-range integers raise ValueError, non-integer values for integer codes raise TypeError, and f / d accept integers. Not implemented: s / p strings, e half floats, n / N, and pack_into / unpack_from / iter_unpack.
[92.5, -115.25, 0.75]
4The byte-order prefix picks the layout:
b'\x02\x01'
b'\x01\x02'
[70000]A value that does not fit its code raises ValueError:
out of range: argument out of range for 'B'