code: def byteswap(s):
      
      assert len(s) % 2 == 0
      parts = []
      for i in range(0, len(s), 2):
          chunk = s[i:i + 2]
          newchunk = struct.pack('<h', *struct.unpack('>h', chunk))
          parts.append(newchunk)
      return b''.join(parts)
docs: Swaps the endianness of the bytesting s, which must be an array
      of shorts (16-bit signed integers). This is probably less efficient
      than it should be.