title: Converting bytes to integer using struct.unpack versus sum in Python
body: <p>By looking through various Questions on this site I have found 3 workable methods of reading a 4 byte (32 bit unsigned little-endian) integer from a file. Namely:</p>
  
  <pre><code>1) myInt, = struct.unpack('&lt;I', bytes)
  2) myInt = struct.unpack('&lt;I', bytes)[0]
  3) myInt = sum(bytes[i] &lt;&lt; (i*8) for i in range(4))
  </code></pre>
  
  <p>Which of these is best? I know to use unpack requires importing the struct module but what are the other pros or cons for any particular method.</p>