Dictionary in Python

Gordon McMillan gmcm at hypernet.com
Mon Mar 13 15:36:56 EST 2000


Alex wrote:
> > Does anyone know how dictionary is implemented in Python(such as hash
> > table, heap, linked list)? If my dictionary increases in size, how
> > much is the impact on performace?
> 
> Based on discussions I've seen in the newsgroup, I'm pretty sure it's a
> hash table.  My experience has been that I can stick about 1.5 million
> string keys in a dictionary before collisions start to hurt me.

Yes, it's a hash. No, it's not collisions that are hurting you. 
Maybe it's resizing that hurts, but...
 
> I would love it if there was a way to increase the size of the hash
> table.  I'm sure I have more than enough memory for an order-of-
> magnitude increase.

Order of magnitude, your hash table is taking around 20 Meg 
and your objects at *least* 75 Meg. If you've got the memory, 
it's still entirely possible your OS isn't giving it to you (ie, 
you're swapping).

- Gordon




More information about the Python-list mailing list