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!
asked Feb 20, 2020 at 13:13
Drey
3,3542 gold badges24 silver badges27 bronze badges
-
See the grey "note" box at the beginning of your linked documentation page about alignment.Michael Butscher– Michael Butscher2020年02月20日 13:23:29 +00:00Commented Feb 20, 2020 at 13:23
-
Does this answer your question? Python struct giving incorrect lengthgre_gor– gre_gor2024年02月02日 10:22:01 +00:00Commented Feb 2, 2024 at 10:22
1 Answer 1
Maybe this can help; Python struct giving incorrect length
struct.calcsize('=Hd')
Sign up to request clarification or add additional context in comments.
1 Comment
Drey
Thank you and thanks also to @Michael Butscher for the hint.
lang-py