python的dic真的香

  • 这个图展示了一样的代码,只是从list改成了hashmap的速度变化

假设hashmap是字典
L是List
那么 item in L 查找速度是O(n)
item in hashmap 查找速度是O(1)
并且单独用 in hashmap.keys() in hashmap.values()会更快!!!

猜你喜欢

转载自blog.csdn.net/weixin_39666736/article/details/104289242
DIC