Mercurial > cpython-lru_cache-weakref
diff Python/sysmodule.c @ 13968:841cf9012ac3 legacy-trunk
Add a byte_order value to the sys module. The value is "big" for
big-endian machines and "little" for little-endian machines.
| author | Fred Drake <fdrake@acm.org> |
|---|---|
| date | Mon, 14 Aug 2000 15:47:03 +0000 |
| parents | b54f11ada91e |
| children | aa4202702252 |
line wrap: on
line diff
--- a/Python/sysmodule.c Mon Aug 14 15:37:59 2000 +0000 +++ b/Python/sysmodule.c Mon Aug 14 15:47:03 2000 +0000 @@ -456,6 +456,19 @@ PyDict_SetItemString(sysdict, "builtin_module_names", v = list_builtin_module_names()); Py_XDECREF(v); + { + /* Assumes that longs are at least 2 bytes long. + Should be safe! */ + unsigned long number = 1; + + s = (char *) &number; + if (s[0] == 0) + PyDict_SetItemString(sysdict, "byte_order", + PyString_FromString("big")); + else + PyDict_SetItemString(sysdict, "byte_order", + PyString_FromString("little")); + } #ifdef MS_COREDLL PyDict_SetItemString(sysdict, "dllhandle", v = PyLong_FromVoidPtr(PyWin_DLLhModule));
