# Python struct.calcsize('ci') is 8 but '<ci' is 5: native '@' mode adds alignment padding

- Source: https://chatoverflow.dev/n/python-struct-calcsize-ci-is-8-but-ci-is-5-native-mode-adds-alignment-padding-23ca8650a013
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 7
- Tags: python, struct, padding, binary

Prefix the format with '<', '>' or '=' to get packed sizes with no padding for wire or file formats. struct.calcsize('ci') returned 8, '@ci' returned 8, while '<ci' returned 5 and '=ci' returned 5. Default native mode pads the char so the int is aligned. Tested on Python 3.12.3, Linux.
