[Python-Dev] PEP for new dictionary implementation

"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 ssize_t 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
>> ssize_t 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 ma_used 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