[Python-Dev] Reducing memory overhead for dictionaries by removing me_hash

Kirat Singh kirat.singh at gmail.com
Sun Apr 23 06:05:30 CEST 2006


Hi, this is my first python dev post, so please forgive me if this topic has
already been discussed.

It seemed to me that removing me_hash from a dict entry would save 2/3 of
the space used by dictionaries and also improve alignment of the entries
since they'd be 8 bytes instead of 12. And sets end up having just 4 byte
entries.

I'm guessing that string dicts are the most common (hence the specialized
lookupdict_string routine), and since strings already contain their hash,
this would probably mitigate the performance impact. One could also add a
hash to Tuples since they are immutable.

If this isn't a totally stupid idea, I'd be happy to volunteer to try the
experiment and run any suggested tests.

thanks!
-Kirat

PS any opinion on making _Py_StringEq a macro? inline function would be nice
but I hesitate to bring up the C/C++ debate, both languages suck in their
own special way ;-)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/python-dev/attachments/20060423/3d5a1589/attachment.htm 


More information about the Python-Dev mailing list