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.

classification
Title: struct: per item endianess specification
Type: enhancement Stage:
Components: Library (Lib) Versions: Python 2.6
process
Status: closed Resolution: rejected
Dependencies: Superseder:
Assigned To: Nosy List: mark.dickinson, neologix, rhettinger, shaddybaddah
Priority: normal Keywords:

Created on 2008-12-02 06:26 by shaddybaddah, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (4)
msg76726 - (view) Author: Shaddy Baddah (shaddybaddah) Date: 2008-12-02 06:26
I note that using the struct module, a user can specify if number items
of the format are to be interpreted as either big or small endian.
However the format specifier can only accept one indicator character at
its first character to apply for all number items in it. e.g:

"<HI" specifies that both the unsigned short and unsigned int are to be
interpreted as little endian values.

It would be nice to be able to instead do "<>HI" where the first '<'
character indicates the default endianess (for compatibility purposes)
and then the second '>' character indicates that the unsigned short
should be interpreted as big endian. The unsigned int defaults to small
endian as per the first character.
msg102566 - (view) Author: Charles-François Natali (neologix) * (Python committer) Date: 2010-04-07 20:56
I don't see any reasonale reason for mixing endianess inside a struct, and don't know of any real-life protocol using per-item endianess.
Unless someone comes up with a good reason for doing so, and since no one else seems to be interested by this issue, I'd suggest to close it.
msg102568 - (view) Author: Mark Dickinson (mark.dickinson) * (Python committer) Date: 2010-04-07 21:39
I agree that this seems like something that would rarely be needed.  If it's really necessary, it's possible to break up the format and do the packing/unpacking in fixed-endian pieces.
msg102570 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2010-04-07 22:06
FWIW, I concur with Mark and Charles-Francois.
History
Date User Action Args
2022-04-11 14:56:41adminsetgithub: 48734
2010-04-07 22:06:36rhettingersetnosy: + rhettinger
messages: + msg102570
2010-04-07 21:39:46mark.dickinsonsetstatus: open -> closed

nosy: + mark.dickinson
messages: + msg102568

resolution: rejected
2010-04-07 20:56:48neologixsetnosy: + neologix
messages: + msg102566
2008-12-02 06:26:43shaddybaddahcreate