Real Python
  • Start Here
  • Learn Python
    Python Tutorials →
    In-depth articles and video courses
    Learning Paths →
    Guided study plans for accelerated learning
    Quizzes & Exercises →
    Check your learning progress
    Browse Topics →
    Focus on a specific area or skill level
    Community Chat →
    Learn with other Pythonistas
    Office Hours →
    Live Q&A calls with Python experts
    Podcast →
    Hear what’s new in the world of Python
    Books →
    Round out your knowledge and learn offline
    Reference →
    Concise definitions for common Python terms
    Code Mentor →Beta
    Personalized code assistance & learning tools
    Unlock All Content →
  • More
    Learner Stories Python Newsletter Python Job Board Meet the Team Become a Tutorial Writer Become a Video Instructor
  • Search
/
  • Join
  • Sign‑In

— FREE Email Series —

🐍 Python Tricks 💌

Python Tricks Dictionary Merge

🔒 No spam. Unsubscribe any time.

Browse Topics Guided Learning Paths
Basics Intermediate Advanced
ai algorithms api best-practices career community databases data-science data-structures data-viz devops django docker editors flask front-end gamedev gui machine-learning news numpy projects python stdlib testing tools web-dev web-scraping

Table of Contents

  • Get to Know the Hash Table Data Structure
    • Hash Table vs Dictionary
    • Hash Table: An Array With a Hash Function
  • Understand the Hash Function
    • Examine Python’s Built-in hash()
    • Dive Deeper Into Python’s hash()
    • Identify Hash Function Properties
    • Compare an Object’s Identity With Its Hash
    • Make Your Own Hash Function
  • Build a Hash Table Prototype in Python With TDD
    • Take a Crash Course in Test-Driven Development
    • Define a Custom HashTable Class
    • Insert a Key-Value Pair
    • Find a Value by Key
    • Delete a Key-Value Pair
    • Update the Value of an Existing Pair
    • Get the Key-Value Pairs
    • Use Defensive Copying
    • Get the Keys and Values
    • Report the Hash Table’s Length
    • Make the Hash Table Iterable
    • Represent the Hash Table in Text
    • Test the Equality of Hash Tables
  • Resolve Hash Code Collisions
    • Find Collided Keys Through Linear Probing
    • Use Linear Probing in the HashTable Class
    • Let the Hash Table Resize Automatically
    • Calculate the Load Factor
    • Isolate Collided Keys With Separate Chaining
  • Retain Insertion Order in a Hash Table
  • Use Hashable Keys
    • Hashability vs Immutability
    • The Hash-Equal Contract
  • Conclusion