[Python-Dev] PEP for new dictionary implementation (original) (raw)

"Martin v. Löwis" martin at v.loewis.de
Mon Feb 20 00:20:39 CET 2012


Ah, now I understand; you do need a single ssizet either on the dict or at the head of the values array to indicate how many slots it has actually allocated. It may also be worthwhile to add a second ssizet to indicate how many are currently in use, for faster results in case of len. But the dict is guaranteed to have at least one free slot, so that extra index will never make the allocation larger than the current code. The dict already has a field indicating how many items are in use, the maused field.

So what do you think about Jim's proposal to make the values indexed not by hash value, but by an index that is stored in the shared keys?

Since the load will be < 2/3, this should save 1/3 of the value storage (typically more than that, if you initialize the values array always to the current number of shared keys).

Regards, Martin



More information about the Python-Dev mailing list