Issue 1709506: struct.calcsize() incorrect - Python tracker (original) (raw)

Issue1709506

Created on 2007-04-29 07:21 by joelbondurant, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (2)
msg31916 - (view) Author: JoelBondurant (joelbondurant) Date: 2007-04-29 07:21
The result of: import struct struct.calcsize('cd') #returns 16 appears to be incorrect. The correct result should be 1 + 8 = 9.
msg31917 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2007-04-29 10:38
No, the result is correct as it stands. If you define struct Foo{ char c; double d; }; on your system, and then compute sizeof(struct Foo) using the C compiler, it will tell you that the struct is 16 bytes in size. Read some text about alignment and padding.
History
Date User Action Args
2022-04-11 14:56:24 admin set github: 44912
2007-04-29 07:21:27 joelbondurant create