[Python-Dev] More compact dictionaries with faster iteration

Serhiy Storchaka storchaka at gmail.com
Mon Dec 10 10:12:27 CET 2012


On 10.12.12 09:48, Christian Heimes wrote:
> On the other hand every lookup and collision checks needs an additional
> multiplication, addition and pointer dereferencing:
>
>    entry = entries_baseaddr + sizeof(PyDictKeyEntry) * idx

I think that main slowdown will be in getting index from array with 
variable size of elements. It requires conditional jump which is not 
such cheap as additional or shifting.

     switch (self->index_size) {
     case 1: idx = ((uint8_t *)self->indices)[i]; break;
     case 2: idx = ((uint16_t *)self->indices)[i]; break;
     ...
     }

I think that variable-size indices don't worth effort.




More information about the Python-Dev mailing list