A hashable object is a Python object that provides a hash value and can therefore serve as a dictionary key. Hashing lets a dictionary locate a key directly instead of scanning every item, making lookup effectively constant-time as the collection grows. section 5.1
When choosing dictionary keys, remember:
- Use hashable values such as numbers or strings as keys. section 5.20
- Keep values unrestricted: a value may be anything, including another dictionary. section 5.20
- Expect keys to be unique; hashing supports efficient key searches. section 5.1 section 5.20
Choose the key, then store any value
Use a string or number for the dictionary key, then attach the data you need: a key such as "Smith" can identify a record whose value could itself be another dictionary. If several entries need the same key, the keys are not distinct. section 5.1 section 5.20


