struct.pack
is usually used to access memory structures, not files. In memory, accessing data which occupies several bytes at an odd/unaligned address can cause exceptions or performance loss.
That's why compilers align the data (usually on a 4 or 8 byte boundary) and the struct
module in Python does the same.
To disable this, you can use the first character of the format string to set the byte order and alignment. In your case, try struct.pack("=bi",1,1)
If you don't specify anything, then an implicit @
which means "native byte order, size and alignment". See the documentation for other options.