How do Python Dictionary Searching works?

Dicts are hash tables. No tree searching is used. Looking up a key is a nearly constant time(Amortized constant) operation, regardless of the size of the dict. It creates the hash of the key, then proceeds to find the location associated with the hashed value. If a collision listed address is encountered, it starts the collision resolution algorithm to find the actual value.

This causes dictionaries to take up more space as they are sparse.

Lakshmi Srinivas
Lakshmi Srinivas

Programmer / Analyst / Technician