[Python-ideas] Ordered storage of keyword arguments

Antoine Pitrou solipsis at pitrou.net
Thu Oct 28 20:06:05 CEST 2010

On Thu, 28 Oct 2010 19:58:59 +0200
spir <denis.spir at gmail.com> wrote:
> On Thu, 28 Oct 2010 07:58:08 -0700
> Guido van Rossum <guido at python.org> wrote:
> > Let's see if someone can come up with an ordereddict implemented in C
> > first and then benchmark the hell out of it.
> > 
> > Once its performance is acceptable we can talk about using it for
> > keyword args, class dicts, or even make it the one and only dict
> > object -- but the latter would be a really high bar to pass.
> > 
> What does the current implementation use as buckets?

It uses an open addressing strategy. Each dict entry holds three
pointer-sized fields: key object, value object, and cached hash value
of the key.
(set entries have only two fields, since they don't hold a value object)

You'll find details in Include/dictobject.h and Objects/dictobject.c.



More information about the Python-ideas mailing list