title: Low Performance unpacking byte array to data structure
body: <p>I've some performance trouble to put data from a byte array to the internal data structure. The data contains several nested arrays and can be extracted as the attached code. In C it takes something like one Second by reading from a stream, but in Python it takes almost one Minute. I guess indexing and calling int.from_bytes was not the best idea.
  Has anybody a proposal to improve the performance?</p>
  <pre><code>...
  ycnt = int.from_bytes(bytedat[idx:idx + 4], 'little')
  idx += 4
  while ycnt &gt; 0:
      ky = int.from_bytes(bytedat[idx:idx + 4], 'little')
      idx += 4
      dv = DataObject()
      xvec.update({ky: dv})
      dv.x = int.from_bytes(bytedat[idx:idx + 4], 'little')
      idx += 4
      dv.y = int.from_bytes(bytedat[idx:idx + 4], 'little')
      idx += 4
      cntv = int.from_bytes(bytedat[idx:idx + 4], 'little')
      idx += 4
      while cntv &gt; 0:
          dv.data_values.append(int.from_bytes(bytedat[idx:idx + 4], 'little', signed=True))
          idx += 4
          cntv -= 1
      dv.score = struct.unpack('d', bytedat[idx:idx + 8])[0]
      idx += 8
      ycnt -= 1
  ...
  </code></pre>