Endianness conversion

Daniel Harding dharding at gmail.com
Sat Feb 24 12:27:19 EST 2007


On Feb 24, 9:39 am, Toby <etat... at gmail.com> wrote:
> As part of a program I'm writing, I need to save to disk big amounts of
> data (hundreds of MB, in 8kB chunks) swapping every couple of bytes.
>
> I obviously cannot do it in a Python loop.
>
> Is there a function I could use in the standard library, or do I have to
> write my own C extension?

Try the using the array module.  array objects provide a byteswap
method which reverses endianness.

-Daniel




More information about the Python-list mailing list