Reputation: 31
What's the difference between a hashmap and hashtable in Python?
I know they are implemented as a dictionary container but to my knowledge, hashmaps are synchronized so they can only be operated on by one task/function at a time while hashtables can be operated on by multiple threads at once. I'm pretty sure the dictionary is a hashmap since it allows a 'None' key and 'None' values, so what would a hashtable be in Python?
Upvotes: 1
Views: 4126
Reputation: 155438
You're making an artificial distinction based on Java's collection types. In normal programming jargon, a hash map and a hash table are the same thing.
Python's dict
type is more analogous to HashMap
(in that it doesn't inherently provide any synchronization guarantees). If you want synchronization, you need to handle it yourself (threading.Lock
with a with
statement makes this pretty easy).
Upvotes: 7