Struct Endianness in Python
til.simonwillison.net
til.simonwillison.net
Docs: https://docs.python.org/3/library/struct.html#format-charact...
sys.byteorder
Cool. Handy way to do a quick check. I didn't realize Raspbian on Pi is little-endian.
Most I've used struct is with XBee ZigBee protocol, which uses big-endian.
When you're churning through a lot of data, instantiating a Struct object will give a nice speedup vs. passing in the format string on every pack/unpack.
int.to_bytes and bytes.to_int requires a byteorder argument, curious that struct doesn't