<div dir="ltr"><br><br><div class="gmail_quote">On Sun, Feb 26, 2012 at 12:33, pmon mail <span dir="ltr">&lt;<a href="mailto:pmon.mail@gmail.com">pmon.mail@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<div dir="ltr">Hi<div><br></div><div>I have found myself in the following troubling situation.</div><div><br></div><div>I&#39;m running the following code on a Python 2.6.5 on Linux x86:</div><div><div><font face="&#39;courier new&#39;, monospace"><div>


Python 2.6.5 (r265:79063, Apr 16 2010, 13:09:56) </div><div>[GCC 4.4.3] on linux2</div><div>Type &quot;help&quot;, &quot;copyright&quot;, &quot;credits&quot; or &quot;license&quot; for more information.</div><div>&gt;&gt;&gt; import struct</div>


<div>&gt;&gt;&gt; len(struct.pack(&#39;L&#39;,0))</div><div>4</div></font></div></div><div><br></div><div>Works as expected and documented (<a href="http://docs.python.org/library/struct.html" target="_blank">http://docs.python.org/library/struct.html</a>).</div>


<div><br></div><div>I&#39;m running the same code on a MacPro (OS X 10.7.3) and I&#39;m getting the following:</div><div><div><font face="&#39;courier new&#39;, monospace">Python 2.7.1 (r271:86832, Jun 16 2011, 16:59:05) </font></div>


<div><font face="&#39;courier new&#39;, monospace">[GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)] on darwin</font></div><div><font face="&#39;courier new&#39;, monospace">Type &quot;help&quot;, &quot;copyright&quot;, &quot;credits&quot; or &quot;license&quot; for more information.</font></div>


<div><font face="&#39;courier new&#39;, monospace">&gt;&gt;&gt; import struct</font></div><div><font face="&#39;courier new&#39;, monospace">&gt;&gt;&gt; len(struct.pack(&#39;L&#39;,0))</font></div>
<div><font color="#ff0000" face="&#39;courier new&#39;, monospace">8</font></div></div><div><br></div><div>Documentation clearly states that the &#39;L&#39; is a 4 byte integer.</div><div><br></div>
<div>Is this a bug? I&#39;m I missing something?</div><br></div></blockquote></div><br>By default pack uses native size, not standard size. On a 64-bit machine:<br><br>&gt;&gt;&gt; struct.pack(&#39;=L&#39;, 0)<br>&#39;\x00\x00\x00\x00&#39;<br>

&gt;&gt;&gt; struct.pack(&#39;L&#39;, 0)<br>&#39;\x00\x00\x00\x00\x00\x00\x00\x00&#39;<br><br><br><br></div>