[Python-Dev] Optimization of the Year

Aahz aahz at pythoncraft.com
Tue Feb 10 11:39:04 EST 2004


On Tue, Feb 10, 2004, Tim Peters wrote:
> [Tim]
>> ...
>> Guido explained it:  we can add one 4-byte field to the list object
>> header on a 32-bit box for free now, but adding two grows every list
>> object by 8 bytes.
> 
> To be more precise, we can add one 4-byte field for free on 32-bit
> boxes under compilers where "long double" has 4-byte alignment.  We
> can't add anything for free under compilers where "long double" has
> 8-byte alignment; this includes Microsoft's compiler, alas.  (The gc
> header is forced to long double alignment via a union trick, and that
> makes the gc header consume 16 bytes (4 of them unused padding) under
> MSVC.)

So in other words, we might as well go ahead and trade space for speed?
If someone really does have a million small lists, they're probably
mutating some of them constantly (or they'd use tuples).
-- 
Aahz (aahz at pythoncraft.com)           <*>         http://www.pythoncraft.com/

"The joy of coding Python should be in seeing short, concise, readable
classes that express a lot of action in a small amount of clear code -- 
not in reams of trivial code that bores the reader to death."  --GvR



More information about the Python-Dev mailing list