[Numpy-discussion] Native byteorder representation

Francesc Altet faltet@carabos....
Fri Feb 2 12:42:24 CST 2007


El dv 02 de 02 del 2007 a les 19:11 +0100, en/na Francesc Altet va
escriure:
> El dv 02 de 02 del 2007 a les 10:22 -0700, en/na Travis Oliphant va
> escriure:
> > Francesc Altet wrote:
> > 
> > >Hi,
> > >
> > >We have been bitten by a small glitch related with the representation of 
> > >native byteorders. Here is an example exposing the problem:
> > >
> > >  
> > >
> > >>>>numpy.dtype('<i4').byteorder
> > >>>>        
> > >>>>
> > >'='
> > >  
> > >
> > >>>>numpy.dtype('>i4').newbyteorder('little').byteorder
> > >>>>        
> > >>>>
> > >'<'
> > >
> > >  
> > >
> > This is somewhat inconsistent.  But, I'm not sure it's worth changing.  
> > 
> > In the second case, you request a "little" byteorder data-type.  Keeping 
> > this as '<' seems O.K.
> > 
> > One could instead ask why the first example did not report a byte-order 
> > of "<" when that's what was explicitly asked for.
> 
> Well, just because of the same reason that
> 
> numpy.dtype('<i4').byteorder
> 
> returns a '=' instead of a '<' (the latter being explicitely set in the
> constructor).

Ops. I was confused about what you was saying here, sorry. Forget this.

> 
> I think that returning a '=' whenever the byteorder is the same than the
> underlying machine is desirable because the user can quickly see whether
> her data is in native order or not.

I think that this is the only reason I can argue.

-- 
Francesc Altet    |  Be careful about using the following code --
Carabos Coop. V.  |  I've only proven that it works, 
www.carabos.com   |  I haven't tested it. -- Donald Knuth



More information about the Numpy-discussion mailing list