byte-order · shipping · also Endianness

Byte order

Byte order is the convention that assigns significance to the positions of bytes in a multibyte value.

Integers: Big-endian puts the most significant byte first; little-endian puts it last. For an unsigned 16-bit integer, hexadecimal bytes 01 02 mean 258 in big-endian and 513 in little-endian. Width, signedness and field layout must also be specified. [1]

Conversion: Reinterpreting the same bytes with a different byte-order descriptor differs from swapping the bytes. Starting from big-endian 01 02, changing both preserves 258 while changing either alone gives 513. NumPy exposes these as a dtype view and byteswap(), respectively. [2]

Arrays: Byte order within each element differs from C/Fortran element traversal. In NPY 1.0, the header-length field is little-endian independently of the payload dtype described by the header. [3]

Scalar extraction: For a plain unsigned 16-bit NumPy array, extracting an element returns a native-order scalar without changing the array. The scalar does not retain the source byte order. A simple dtype's byteorder may report = when an explicit order matches the host; inspect the array dtype and raw bytes together. [2] [5]

Relations

related
NumPy NPY format, Checksum, File storage

Citations

  1. Python struct: byte order, size and alignment (accessed 2026-11-06)
  2. NumPy: byte-swapping and dtype reinterpretation (accessed 2026-11-06)
  3. NumPy: NPY format and header fields (accessed 2026-11-06)
  4. NumPy: native and explicit dtype byte order (accessed 2026-11-06)

Further reading

  1. Hesela: reading the same bytes in another order (accessed 2026-11-06)
Sources & caveats
  • Source-reviewed terminology and exact unsigned 16-bit arithmetic; no device or corruption-rate measurement.
  • Executable worked example: https://hesela.dev/research/byte-order.mjs; regression controls: https://hesela.dev/research/byte-order.test.mjs.
  • Native NumPy scalar checks: https://hesela.dev/research/byte-order-native.py; the script reports its library version and host order and checks both explicit byte orders without hardware I/O.

JSON: /data/terms/byte-order.json

Published by Hesela team · Updated

Report a correction · Editorial standards · Reuse guidance

Cite this page
Hesela team. Byte order. Hesela. 2026-11-06. https://hesela.dev/terms/byte-order/