Python Dictionary vs Lists Speed Comparison

preview_player
Показать описание
In this video I demonstrate the speed difference between searching a list vs searching a dictionary.
Рекомендации по теме
Комментарии
Автор

And what if you don’t know the key… I don’t understand your logic

fabcol
Автор

It is also faster if you iterate over the dict since the keys are hashed. So even if you do a

for key in myDict:
if key ==
it would still be much faster than the list

Reecepbcups
Автор

arrays will be faster in work loads where you process information in a specific order without having to search for specific elements. they do have their uses. hash calculations take more time than simply popping off the last element in an array.

Rin-qjzt
Автор

all you did was assign the instance to the value of the dictionary....you didn't return the value from the dictionary so you never searched through this doesn't seem like a good comparison to me...

quitethecontrary
Автор

You're indexing the entire list verse grabbing a specific value from dictionary. This is apples to oranges... you would need to index the dictionary to compare apples to apples.

ryansaunders
Автор

Cool vid! Any reason why you didn't choose to output list in the following way: Looks like you are forcing the list to search one by one, which logically means it will take longer than dict.

kewei