I am using python to receive a string via UDP. From each character in the string I need to extract the 4 pairs of bits and convert these to integers.
For example, if the first character in the string was "J", this is ASCII 0x4a or 0b01001010. So I would extract the pairs of bits [01, 00, 10, 10], which would be converted to [1, 0, 2, 2].
Speed is my number one priority here, so I am looking for a fast way to accomplish this.
Any help is much appreciated, thank you.
a & 0x3will give you the first two bits,a & 0xcthe next two, etc.