> On 2 Feb 2022, at 18:19, Jen Kris via Python-list <python-list@python.org> > wrote: > > It's not clear to me from the struct module whether it can actually > auto-detect endianness.
It is impossible to auto detect endian in the general case. > I think it must be specified, just as I had to do with int.from_bytes(). In > my case endianness was dictated by how the four bytes were populated, > starting with the zero bytes on the left. You can specify the endian explicitly in the format strings. It’s all in the docs. Barry > > > Feb 1, 2022, 21:30 by wlfr...@ix.netcom.com: > >> On Wed, 2 Feb 2022 00:40:22 +0100 (CET), Jen Kris <jenk...@tutanota.com> >> declaimed the following: >> >>> >>> breakup = int.from_bytes(byte_val, "big") >>> >>> print("this is breakup " + str(breakup)) >> >>> >>> >>> Python prints: this is breakup 32894 >> >>> >>> >>> Note that I had to switch from little endian to big endian. Python is >>> little endian by default, but in this case it's big endian. >> >>> >>> >> Look at the struct module. I'm pretty certain it has flags for big or >> little end, or system native (that, or run your integers through the >> various "network byte order" functions that I think C and Python both >> support. >> >> https://www.gta.ufrj.br/ensino/eel878/sockets/htonsman.html >> >> >>> However, if anyone on this list knows how to pass data from a non-Python >>> language to Python in multiprocessing.shared_memory please let me (and the >>> list) know. >> >> <pondering>MMU cache lines not writing through to RAM? Can't find >> anything on Google to force a cache flush</pondering> Can you test on a >> different OS? (Windows vs Linux) >> >> >> >> -- >> Wulfraed Dennis Lee Bieber AF6VN >> wlfr...@ix.netcom.com http://wlfraed.microdiversity.freeddns.org/ >> -- >> https://mail.python.org/mailman/listinfo/python-list >> > > -- > https://mail.python.org/mailman/listinfo/python-list -- https://mail.python.org/mailman/listinfo/python-list