If you only need to perform byte decompression, then the struct module is your friend (see eryksun answer), as well as bytearray Type:
>>> ba = bytearray('\xae\x02\x59')
This allows indexing and slicing at byte level.
>>> hex(ba[0]) '0xae' >>> ba[1:3] bytearray(b'\x02Y')
In terms of converting multiple bytes to int, this is very useful, but you are unlikely to get much more struct if you don't have unusual byte lengths. Converting two bytes to int will be:
>>> (ba[1] << 8) + ba[2] 601
In the commentary, you say that you need a general way to perform a bitwise slice. I'm afraid there is nobody - your best place to start is switching and disguising with bytearray. This is why useful modules such as bitstring are useful (I wrote this by the way) - you make someone make all the tedious mistakes! / p>
>>> b = bitstring.Bits(ba) >>> b[8:].uint 601 >>> b.unpack('hex:8, uint:16') ['ae', 601]
source share