I need to unwrap raw bytes to bits. Now I have a raw data and a lookup table. What is the most efficient way to iterate over input data to generate output? Or maybe there is another way to do this?
#Look up table looks something like this.
lookup = {
  0: b'\x00\x00\x00\x00\x00\x00\x00\x00',
  1: b'\x00\x00\x00\x00\x00\x00\x00\x01',
  2: b'\x00\x00\x00\x00\x00\x00\x01\x00',
  ...
  255: b'\x01\x01\x01\x01\x01\x01\x01\x01',
}
def remap(data):
  out = [lookup(byte) for byte in data]
  row = b''.join(out)
Here are functions that take most time:
ncalls  tottime  percall  cumtime  percall filename:lineno(function)
44000    2.843    0.000    2.843    0.000 main.py:59(<listcomp>)
44007    0.593    0.000    0.593    0.000 {method 'join' of 'bytes' objects}
 
    