title: How is int.from_bytes() calculated?
body: <p>I am trying to understand what <code>from_bytes()</code> actually does.</p>
  
  <p>The <a href="https://docs.python.org/3/library/stdtypes.html#int.from_bytes" rel="noreferrer">documentation mention this</a>:</p>
  
  <blockquote>
    <p>The byteorder argument determines the byte order used to represent the integer. If byteorder is "big", the most significant byte is at the beginning of the byte array. If byteorder is "little", the most significant byte is at the end of the byte array. To request the native byte order of the host system, use sys.byteorder as the byte order value.</p>
  </blockquote>
  
  <p>But this does not really tell me how the bytes values are actually calculated. For example I have this set of bytes:</p>
  
  <pre><code>In [1]: byte = b'\xe6\x04\x00\x00'
  
  In [2]: int.from_bytes(byte, 'little')
  Out[2]: 1254
  
  In [3]: int.from_bytes(byte, 'big')
  Out[3]: 3859021824
  
  In [4]:
  </code></pre>
  
  <p>I tried <code>ord()</code> and it returns this:</p>
  
  <pre><code>In [4]: ord(b'\xe6')
  Out[4]: 230
  
  In [5]: ord(b'\x04')
  Out[5]: 4
  
  In [6]: ord(b'\x00')
  Out[6]: 0
  
  In [7]:
  </code></pre>
  
  <p>I don't see how either <code>1254</code> or <code>3859021824</code> was calculated from the values above.</p>
  
  <p>I also found <a href="https://stackoverflow.com/questions/8830917/endianness-most-significant-and-least-significant">this question</a> but it does not seem to explain exactly how it works. </p>
  
  <p>So how is it calculated?</p>