[英]What's the difference between a hashmap and a hashtable in Python?
What's the difference between a hashmap and hashtable in Python? Python 中的 hashmap 和 hashtable 有什么区别?
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?
我很确定字典是一个哈希图,因为它允许“无”键和“无”值,那么 Python 中的哈希表是什么?
You're making an artificial distinction based on Java's collection types.您正在根据 Java 的集合类型进行人为的区分。 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). Python 的
dict
类型更类似于HashMap
(因为它本质上不提供任何同步保证)。 If you want synchronization, you need to handle it yourself ( threading.Lock
with a with
statement makes this pretty easy).如果你想要同步,你需要自己处理(
threading.Lock
和with
语句使这很容易)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.