From: Arlindo da S. <da...@al...> - 2008-06-20 01:11:45
|
All, I just realized that on both Mac OS X 8.5/Intel and Linux/Ubuntu 8.04 I always get os.byteorder='big' with Jython, while CPython gives me os.byteorder='little' as expected. This is probably a reflection of the fact that the JVM is big-endian regardless of the endianess of the underlying hardware. This could explain the automatic byteswapping in my original posting. Can someone confirm this? Arlindo On Thu, Jun 19, 2008 at 2:12 PM, Arlindo da Silva <da...@al...> wrote: > All, > > I'm porting some scripts from CPython to Jython and I am running into > some I/O issue that perhaps someone could clarify whether this is a bug or a > feature of jython v2.2.1. Basically, I am loading some floats from a binary > stream into an array. Something like, > > import array > a = array.array('f') > a.fromfile(Reader,10) > > where Reader is actually the stdout of a C program captured with popen2(): > > Reader, Writer = popen2(cmdline,bufsize=0) > > On CPython 2.5 I get the values as expected. Under jython, the numbers are > byte swapped, that is, a.byteswap() produce the correct values. It appears > that somewhere along jython is assuming that the Reader stream is in network > byte order and doing the swap for me. Not surprisingly, I have no problem > getting strings from Reader. > > Is there a way for me to disable this automatic byte swap when reading > floats? > > Thank you, > > Arlindo > > -- > Arlindo da Silva > da...@al... -- Arlindo da Silva da...@al... |