[Tutor] what is 'doubleword alignment'?

Walter Prins wprins at gmail.com
Sun Jul 17 17:45:52 CEST 2011


On 17 July 2011 15:26, Lisi <lisi.reisz at gmail.com> wrote:

> Sorry to be slow.  Blame virtually no sleep last night ;-(  But even were
> the
> power of two bit correct (and I see subsequently that it is not), how is 18
> a
> power of two?
>
>
The 18 bytes is a bit of an irrelevance.  The point is that if the start of
the buffer falls on a dword (double word) alligned memory location then in
theory the access should be faster.  The term is a little bit ambiguous
because strictly speaking different processors have different word sizes.
Even so, usually when people speak of double-word alignment, it's often the
case that the term word in such a context has its original meaning, e.g. 16
bits.  A dword is then 32bits or 4 bytes.   A doubleword aligned memory
address is, using these assumptions, therefore an address that is divisible
by 4.  Obviously if the word size is 32bits, then a double word would be
64bits and a doubleword aligned address would need to be divisible by 8.  As
an aside, this type of optimization is often taken care of by compilers
under the hood, and in any case it's generally not something that you'll
really be considering as a Python programmer.  (If however you were working
on one of the Python runtimes or implementations, then you might well be
sometimes considering this type of thing, depending on exactly how
performance critical what you are working might be and what the runtime was
being implemented in.)

Regards

Walter
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20110717/6a51a81c/attachment-0001.html>


More information about the Tutor mailing list