[Numpy-discussion] byteswap() leaves dtype unchanged

Matthew Brett matthew.brett at gmail.com
Thu May 31 04:13:48 EDT 2007


Hi,

> > I can see your point I think, that situation 1 seems to be the more
> > common and obvious, and coming at it from outside, you would have
> > thought that a.byteswap would change both.
>
> I think the reason that byteswap behaves the way it does is that for
> situation 1 you often don't actually need to do anything. Just
> calculate with the things (it'll be a bit slow); as soon as the first
> copy gets made you're back to native byte order. So for those times
> you need to do it in place it's not too much trouble to byteswap and
> adjust the byte order in the dtype (you'd need to inspect the byte
> order in the first place to know it was byteswapped...)

Thanks - good point. How about the following suggestion:

For the next release:

rename byteswap to something like byteswapbuffer
deprecate byteswap in favor of byteswapbuffer

Update the docstrings to make the distinction between situations clearer.

I think that would reduce the clear element of surprise here.

Best,

Matthew



More information about the NumPy-Discussion mailing list