This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author mark.dickinson
Recipients eric.smith, mark.dickinson, sgk284
Date 2009-11-19.19:10:20
SpamBayes Score 9.802183e-07
Marked as misclassified No
Message-id <1258657822.0.0.604907120759.issue7355@psf.upfronthosting.co.za>
In-reply-to
Content
> Just for clarification, why does "ci" get padded but "ic" doesn't?

Because no padding is necessary in the second case:  both the integer and 
the character already start at a position that's a multiple of 4---the 
integer at position 0 and the character at position 4.

In the first case, without padding, the integer wouldn't start at a word 
boundary.

The aim is to make sure that the byte sequence output by struct.pack 
matches the layout of a corresponding C struct.  In the first case inter-
item padding is necessary to make that work, in the second it isn't.

You could argue that in the second case, Python should add trailing 
padding, but I'm not sure what the point would be.
History
Date User Action Args
2009-11-19 19:10:22mark.dickinsonsetrecipients: + mark.dickinson, eric.smith, sgk284
2009-11-19 19:10:21mark.dickinsonsetmessageid: <1258657822.0.0.604907120759.issue7355@psf.upfronthosting.co.za>
2009-11-19 19:10:20mark.dickinsonlinkissue7355 messages
2009-11-19 19:10:20mark.dickinsoncreate