Author mark.dickinson
Recipients Alexander.Belopolsky, MrJean1, ajaksu2, barry, benjamin.peterson, inducer, mark.dickinson, meador.inge, noufal, pitrou, teoliphant
Date 2010-05-20.16:24:47
SpamBayes Score 2.4306e-05
Marked as misclassified No
Message-id <>
After a bit more thought (and after soliciting a couple of opinions on #python-dev), I'm convinced that endianness changes within a substruct should be local to that substruct:

- it makes the meaning of '>2T{H<H}' both unsurprising and easy to understand:  i.e., it would be interpreted exactly as '>T{H<H}T{H<H}', and  both substructs would behave like '>H<H'.

- I suspect it's the behaviour that people expect

- it may make dynamic creation of struct format strings easier/less bug-prone.

But now I've got a new open issue:  how much padding should be inserted/expected (for pack/unpack respectively) between the 'B' and the 'T{...}' in a struct format string of the form 'BT{...}'?

For this, I don't think we can hope to exactly comply with the platform ABI in all cases.  But I think there's a simple rule that would work 99% of the time, and that does match the ABI on common platforms (though I'll check this), namely that the alignment requirement of the 'T{...}' struct should be the least common multiple of the alignment requirements of any of its elements.  (Which will usually translate to the largest of the alignment requirements, since those alignments are usually all going to be powers of 2.)

And *this* is where things get tricky if the alignment/byteorder/size specifier is changed midstream, since then it doesn't seem clear what alignments would contribute to the lcm above.  I'm tempted to suggest that for native mode, changing the specifier be disallowed entirely.

Travis, any comments on any of this?
Date User Action Args
2010-05-20 16:24:49mark.dickinsonsetrecipients: + mark.dickinson, barry, teoliphant, pitrou, inducer, ajaksu2, MrJean1, benjamin.peterson, noufal, meador.inge, Alexander.Belopolsky
2010-05-20 16:24:49mark.dickinsonsetmessageid: <>
2010-05-20 16:24:48mark.dickinsonlinkissue3132 messages
2010-05-20 16:24:47mark.dickinsoncreate