Drey
Drey

Reputation: 3364

Python's `struct` byte size calcualtion

Unfortunately I don't understand the byte size calculation of the struct python module. I use this documentation when encoding my values.

import struct

struct.calcsize('H') # == 2
struct.calcsize('d') # == 8

but

struct.calcsize('Hd') # == 16 != 8+2

using the encoding together requires 16 bytes instead of 10

What could be/is the reason for this? Thanks!

Upvotes: 2

Views: 203

Answers (1)

Yunus ŞAHİN
Yunus ŞAHİN

Reputation: 26

Maybe this can help; Python struct giving incorrect length

struct.calcsize('=Hd')

Upvotes: 1

Related Questions