swapping numeric items in a list
Jiang Nutao
jiangnutao at gmail.com
Wed Aug 23 13:44:54 EDT 2006
Thank you all guys for the help. Guess I'm gonna pick bearophile's way. It's
fast, neat, and easy to read.
array.byteswap() won't work for me easily. I tried this before my 1st post.
I defined
aa = array('H', [0x12, 0x34, 0x56, 0x78])
Then did byteswap aa.byteswap(). The result was
array('H', [0x1200, 0x3400, 0x5600, 0x7800])
You can see it byteswapped within each item.
Jason
"Marc 'BlackJack' Rintsch" <bj_666 at gmx.net> wrote in message
news:pan.2006.08.23.10.13.15.854509 at gmx.net...
> In <mailman.9675.1156291509.27775.python-list at python.org>, Jiang Nutao
> wrote:
>
>> To convert list
>> aa = [0x12, 0x34, 0x56, 0x78]
>> into
>> [0x34, 0x12, 0x78, 0x56]
>>
>> How to do it fast? My real list is huge.
>
> Use the `array` module and the `array.byteswap()` method.
>
> Ciao,
> Marc 'BlackJack' Rintsch
> --
> http://mail.python.org/mailman/listinfo/python-list
>
More information about the Python-list
mailing list