[Python-Dev] A new dict for Xmas?

Mark Shannon mark at hotpy.org
Thu Dec 15 23:18:18 CET 2011

Hi all,

The current dict implementation is getting pretty old,
isn't it time we had a new one (for xmas)?

I have a new dict implementation which allows sharing of keys between 
objects of the same class.
You can check it out here:


For numerical applications, with few instances of user-defined classes,
performance is pretty much unchanged, degrading about 1% for pystones.

For applications that create lots of instances of user-defined classes,
performance is improved and memory savings are large.

For the gcbench benchmark (from unladen swallow),
cpython with the new dict is about 9% faster and, more importantly,
reduces memory use from 99 Mbytes to 61Mbytes (a 38% reduction).

All tests were done on my ancient 32 bit intel linux  machine,
please try it out on your machines and let me know what sort of results 
you get.

By the way it passes all the tests,
but there are strange interactions with weakrefs and the GC.
(Try running the tests, you'll see what I mean)


More information about the Python-Dev mailing list