Paul Rubin wrote:
"Martin P. Hellwig" <martin.hell...@dcuktec.org> writes:
Is there an advantage using shifts and masks over my kitchen type solution?

Weren't you complaining about the 8-to-1 expansion from turning each bit
to an ascii char?

One warning to Martin:

If you want your code portable across systems, watch out for big-endian/little-endian issues, as well as alignment ones. Shift & mask code tends to be highly specific to a particular endian-ness, especially if trying to get multiple bits that cross a byte or word boundary.

Over the years, I know I've seen at least three endian versions for the same 32bit word. Something like abcd, dcba, and cdab.

One advantage of converting first to bitstrings, is that there's just the two places to fix, for portability, the conversion from byte array to bitstring, and the conversion back.

DaveA

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to