Python dictionary is a built-in type that supports key-value pairs. It's the nearest builtin data structure relative to Java's HashMap.

You can declare a dict with key-value pairs set to values:

streetno = {
    "1": "Sachin Tendulkar",
    "2": "Dravid",
    "3": "Sehwag",
    "4": "Laxman",
    "5": "Kohli"
}

You can also set a key-value mapping after creation:

streetno = {}
streetno["1"] = "Sachin Tendulkar"
print(streetno["1"]) # => "Sachin Tendulkar"

Another way to create a dictionary is with the dict() builtin function, but this only works when your keys are valid identifiers:

streetno = dict(one="Sachin Tendulkar", two="Dravid")
print(streetno["one"]) # => "Sachin Tendulkar"
Answer from Alan on Stack Overflow
🌐
GeeksforGeeks
geeksforgeeks.org › python › hash-map-in-python
Hash Map in Python - GeeksforGeeks
October 25, 2025 - A hash map is a data structure that stores key-value pairs and allows fast access, insertion and deletion of values using keys. Python comes with built-in hash maps called dictionaries (dict).
🌐
Medium
medium.com › @conniezhou678 › mastering-data-algorithm-part-27-understanding-hash-map-in-python-aff129447502
Mastering Data Algorithm — Part 27 Understanding Hash Map in Python | by Connie Zhou | Medium
January 6, 2025 - In Python, dictionaries are implemented as hash maps. Here’s a simple custom implementation of a hash map: class HashMap: def __init__(self, size=100): self.size = size self.table = [[] for _ in range(size)] def hash_function(self, key): return hash(key) % self.size def put(self, key, value): index = self.hash_function(key) for pair in self.table[index]: if pair[0] == key: pair[1] = value return self.table[index].append([key, value]) def get(self, key): index = self.hash_function(key) for pair in self.table[index]: if pair[0] == key: return pair[1] return None def remove(self, key): index = self.hash_function(key) for i, pair in enumerate(self.table[index]): if pair[0] == key: del self.table[index][i] return ·
🌐
Medium
medium.com › @abasaeed › understanding-hash-maps-hash-tables-and-hash-sets-in-python-c0a78b1e131
Understanding Hash Maps, Hash Tables, and Hash Sets in Python | by Abdullah Saeed | Medium
July 27, 2023 - #Two Sum: For two sum for example the reason we can make use of a hashmap is because using a hash map, you can store the elements of the array along with their indices as key-value pairs. Then, while iterating through the array, you can quickly check if the complement (target minus the current element) exists in the hash map.
🌐
Roadmap
roadmap.sh › python › hashmap
Hashmaps in Python: Master Implementation and Use Cases
January 28, 2026 - Instead of searching through items with the same input one by one, a hashmap jumps straight to the value you want by using a hash function. A hash function is a mathematical operation that converts a key into a number. This number determines where the value is stored in memory, which explains why lookups are so fast. So instead of scanning every item like you would with a list, Python goes directly to the correct location, ensuring the same output for the same input.
🌐
FreelancingGig
freelancinggig.com › home › what is hashmap in python?
What is HashMap in Python? - Developers, Designers & Freelancers - FreelancingGig
December 16, 2019 - HashMap is mainly the Map which is based on the collection class which is mainly used to store the Key & value pairs, this is denoted like HashMap<Key, Value> and HashMap<K, V>. Such class makes does not any kind of guarantees about the order ...
🌐
Quora
quora.com › Are-Python-dictionaries-like-Java-HashTable-or-HashMap
Are Python dictionaries like Java HashTable or HashMap? - Quora
Python dict: allows None as a key and value. Java HashMap: allows one null key and multiple null values.
Find elsewhere
🌐
Turing
turing.com › kb › how-to-use-hashmap-in-python
All You Need to Know About Using Hashmaps in Python
A hashmap is a data structure that maps keys to their respective value pairs. It makes it easy to find values that are associated with their keys. There is no difference between a dictionary and a hashmap.
🌐
CodeGym
codegym.cc › java blog › learning python › hashmap in python
HashMap in Python
November 13, 2024 - A HashMap is a data structure that stores key-value pairs. The key is a unique identifier, and the value is the data you want to store. In Python, the dictionary data type is the closest equivalent to a HashMap.
🌐
Developer Zone
warner.hashnode.dev › what-is-hashmap-in-python
What is hashmap in Python
July 27, 2022 - This tutorial is aimed at beginners on using hashmap and other key based data structures like their syntax: How do we use them, for what are they good, weak points, their graphical side (drawbacks), or output?
🌐
Substack
jakubkrajewski.substack.com › p › implementing-a-hash-map-in-python
Implementing a Hash Map in Python: A Clean and Simple Approach
December 26, 2024 - It achieves this efficiency by computing a hash of the key, which is then used to determine the appropriate index in an underlying array (often referred to as a "bucket") where the corresponding value should be stored. This hashing technique ensures that operations can be performed in constant time, on average, making the HashMap a highly efficient structure for many applications. In this article, we'll build a simple hash map implementation in Python from scratch.
🌐
StrataScratch
stratascratch.com › blog › easy-guide-to-python-hashmaps
Easy Guide to Python Hashmaps - StrataScratch
December 16, 2024 - Python dictionaries use hash functions internally to map keys to specific memory locations, enabling fast lookups. This makes them highly efficient for tasks like counting, organizing, or creating mappings between datasets. Python hashmaps shine because they allow various types of keys—strings, numbers, or even tuples—as long as the keys are immutable.
🌐
Medium
medium.com › @philip.smalls86 › building-a-custom-hashmap-in-python-an-in-depth-look-f477fd2cbea8
Building a Custom HashMap in Python: An In-Depth Look | by Philip Smalls | Medium
October 11, 2024 - Hashmaps (or hash tables) are a key component of computer science, offering an efficient way to store key-value pairs. Their main strength is that they allow for fast lookups, insertions, and deletions by leveraging the power of hashing.
🌐
YoungWonks
youngwonks.com › blog › python-hashmap
Does Python have a HashMap? What is the equivalent of a HashMap in Python? Is dictionary in Python same as HashMap in Java?
November 26, 2023 - In Python, a HashMap can be compared to a dictionary. It allows us to store key-value pairs where the key is unique. The purpose of HashMap or dictionary in Python is to provide fast access to data based on a unique key.
🌐
Analytics Vidhya
analyticsvidhya.com › home › a guide to python hashmaps
A Guide to Python HashMaps
June 7, 2024 - You can understand the inner workings of hash-based data structures by creating your own Hash Map in Python. A rudimentary implementation includes essential features like insertion, retrieval, deletion, and resizing. This approach uses open addressing for both dynamic scaling and collision resolution. class HashMap: def __init__(self, initial_capacity=8, load_factor=0.75): self.capacity = initial_capacity self.load_factor = load_factor self.size = 0 self.buckets = [None] * self.capacity def _hash(self, key): return hash(key) % self.capacity def _resize(self): old_buckets = self.buckets self.ca
🌐
Edureka
edureka.co › blog › hash-tables-and-hashmaps-in-python
Hash Tables and Hashmaps in Python | Hash Table vs Hashmap | Edureka
November 27, 2024 - Hash Tables and hasmaps in Python are a type of data structures that map keys to their value pairs. They are implemented through dictionaries.
🌐
Educative
educative.io › answers › what-is-a-hashmap-in-python
What is a HashMap in Python?
In Python, a HashMap is also a dictionary. It’s used for efficient data storage and retrieval. The mechanism behind HashMaps in Python is storing key-value pairs, and each key is associated with a specific value.
🌐
W3Schools
w3schools.com › python › python_dsa_hashtables.asp
Hash Tables with Python
Python Variables Variable Names Assign Multiple Values Output Variables Global Variables Variable Exercises Code Challenge Python Data Types
🌐
CodeSignal
codesignal.com › learn › courses › revision-of-python-hashmaps-and-their-use-in-practice › lessons › hashmaps-in-action-solving-real-world-problems-in-python
HashMaps in Action: Solving Real-World Problems in Python
Imagine a scenario in which we need to count votes in an election. We employ a HashMap, where each name is a unique key, and the frequency of that name serves as the associated value. Let's write some Python code to better understand this.