python: {...} is faster than dict(...) (intermediate) anthony explains #223

preview_player
Показать описание
today I talk about why dictionary literals (and other literals) are faster than their function-called counterparts

==========

I won't ask for subscriptions / likes / comments in videos but it really helps the channel. If you have any suggestions or things you'd like to see please comment below!
Рекомендации по теме
Комментарии
Автор

need a little help on this, which is faster and why?
here, dict = {1:"one", 2:"two", 3: "three"}, and target = 2

1. if target in dict:
2. if target in dict.keys():

thank you

a_maxed_out_handle_of__chars
Автор

I've never heard someone pronounce it "tuppel." Took me a moment to realize what you were talking about 😅

unvergebeneid
Автор

Interesting! Similarly [*iterable] seems to be faster than list(iterable), and {*iterable} faster than set(iterable) etc.

xan
Автор

So how do I create an empty set without a function call? 🤔

unvergebeneid