How do Python dictionary hash lookups work?

PythonProgramming

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.

raja
Published on 18-Apr-2018 16:26:49
Advertisements