def __generate_crc16_table():
 result = []
 for byte in range(256):
  crc = 0
  for _ in range(8):
   if ((byte ^ crc) & 1):
    crc = ((crc >> 1) ^ 40961)
   else:
    crc >>= 1
   byte >>= 1
  result.append(crc)
 return result

def __generate_crc16_table ( ) : result = [ ] for byte in range ( 256 ) : crc = 0 for _ in range ( 8 ) : if ( ( byte ^ crc ) & 1 ) : crc = ( ( crc >> 1 ) ^ 40961 ) else : crc >>= 1 byte >>= 1 result . append ( crc ) return result
generates a crc16 lookup table .