<div class="gmail_quote">On Tue, Feb 3, 2009 at 10:29 AM, W W <span dir="ltr"><<a href="mailto:srilyk@gmail.com">srilyk@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br><br><div class="gmail_quote"><div class="Ih2E3d">On Tue, Feb 3, 2009 at 6:25 PM, bob gailer <span dir="ltr"><<a href="mailto:bgailer@gmail.com" target="_blank">bgailer@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
>>> struct.calcsize('s')<br>
1<br>
>>> struct.calcsize('d')<br>
8<br>
>>> struct.calcsize('sd')<br>
16<br>
<br>
Why? Should not that be 9?<br><font color="#888888">
</font></blockquote></div><div><br>>>> struct.calcsize('ds')<br>9<br><br>at least on the current box I'm running. It also gave me this:<br><br>>>> struct.calcsize('sd')<br>12<br><br>
so I must confess suspicion...<br>
<br>HTH though,<br>Wayne<br></div></div>
<br>_______________________________________________<br>
Tutor maillist - <a href="mailto:Tutor@python.org">Tutor@python.org</a><br>
<a href="http://mail.python.org/mailman/listinfo/tutor" target="_blank">http://mail.python.org/mailman/listinfo/tutor</a><br>
<br></blockquote></div><br>More results to chew on:<br><br>>>> struct.calcsize('s')<br>
1<br>>>>
struct.calcsize('d')<br>
8<br>>>>
struct.calcsize('sd')<br>
16<br>>>>
struct.calcsize('ds')<br>
9<br>>>>
struct.calcsize('dss')<br>
10<br>>>>
struct.calcsize('dssssss')<br>
14<br>>>> struct.calcsize('dsd')<br>
24<br>
<br>
I believe it's a matter of alignment:<br><blockquote style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;" class="gmail_quote"><p>Native size and alignment are determined using the C compiler's
<tt class="docutils literal"><span class="pre">sizeof</span></tt> expression. This is always combined with native byte order.</p><p>Standard size and alignment are as follows: no alignment is required for any
type (so you have to use pad bytes); <tt class="xref docutils literal"><span class="pre">short</span></tt> is 2 bytes; <tt class="xref docutils literal"><span class="pre">int</span></tt> and
<tt class="xref docutils literal"><span class="pre">long</span></tt> are 4 bytes; <tt class="xref docutils literal"><span class="pre">long</span> <span class="pre">long</span></tt> (<tt class="xref docutils literal"><span class="pre">__int64</span></tt> on Windows) is 8
bytes; <tt class="xref docutils literal"><span class="pre">float</span></tt> and <tt class="xref docutils literal"><span class="pre">double</span></tt> are 32-bit and 64-bit IEEE floating
point numbers, respectively. <tt class="xref docutils literal"><span class="pre">_Bool</span></tt> is 1 byte.</p></blockquote>
<br>-- <br><a href="http://www.fsrtechnologies.com">www.fsrtechnologies.com</a><br>