title: Differences in Python's packed binary data size among platforms?
body: <p>I'm trying to 'unpack' (using Python's struct module) a bytearray to multiple variables, using a formatted string:</p>
  
  <pre><code>(a, b, c, d, e, f, g, h) = unpack('HHHHHBBL', my_byte_array)
  </code></pre>
  
  <p>I expect (when I read the <a href="https://docs.python.org/3/library/struct.html#format-characters" rel="nofollow noreferrer">docs</a>) that:</p>
  
  <ul>
  <li><em>a</em> through <em>e</em> will be an <em>unsigned short</em> (of a size 2 bytes each)</li>
  <li><em>f</em> and <em>g</em> will be an <em>unsigned char</em> (with a size of 1 byte each)</li>
  <li><em>h</em> will be an <em>unsigned long</em> (with a size of of 8 bytes)</li>
  </ul>
  
  <p>When I run this on my Windows 10 machine, this is exactly what I get.</p>
  
  <p>On my other two machines with Mac OS X and Manjaro Linux (all three have Python 3.7 installed), I will get an error stating:</p>
  
  <pre><code>struct.error: unpack requires a buffer of 24 bytes
  </code></pre>
  
  <p>When I run the following, the output is the same on all three machines </p>
  
  <pre><code>&gt;&gt;&gt; from struct import *
  &gt;&gt;&gt; calcsize('H')
  2
  &gt;&gt;&gt; calcsize('B')
  1
  &gt;&gt;&gt; calcsize('L')
  8
  </code></pre>
  
  <p>But when I run the following: </p>
  
  <pre><code>&gt;&gt;&gt; calcsize('HHHHHBBL')
  </code></pre>
  
  <p>The Output on my Windows machine is <em>16</em>, but on the other two systems <em>24</em>. Which seems strange to me, what is going on here?</p>
  
  <p>And how should I use <em>struct.unpack</em> in a multiplatform environment? </p>