Python Forum
what does sys.byteorder() return for others? - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: General (https://python-forum.io/forum-1.html)
+--- Forum: News and Discussions (https://python-forum.io/forum-31.html)
+--- Thread: what does sys.byteorder() return for others? (/thread-20854.html)



what does sys.byteorder() return for others? - Skaperen - Sep-02-2019

documentation describes sys.byteorder() as returning "little" for little-endian, and "big" for big-endian. what would it return for other byte orders like PDP-11 32-bit mode which is neither of those?


RE: what does sys.byteorder() return for others? - Gribouillis - Sep-03-2019

I guess the best way to know this is to purchase a PDP-11 and try.

Edit: in sysmodule.c, there is
#if PY_BIG_ENDIAN
    SET_SYS_FROM_STRING("byteorder",
                        PyUnicode_FromString("big"));
#else
    SET_SYS_FROM_STRING("byteorder",
                        PyUnicode_FromString("little"));
#endif
whereas PY_BIG_ENDIAN is defined in pyport.h
#ifdef WORDS_BIGENDIAN
#define PY_BIG_ENDIAN 1
#define PY_LITTLE_ENDIAN 0
#else
#define PY_BIG_ENDIAN 0
#define PY_LITTLE_ENDIAN 1
#endif
For WORDS_BIGENDIAN, it seems that you need to understand the cryptic 'configure' script. Apparently, there may be some error message if the endianness is undefined. Python may well not compile on such platforms.


RE: what does sys.byteorder() return for others? - Skaperen - Sep-04-2019

i don't think python has been ported to a PDP-11 or its 16-bit OS.