Yakko Majuri
Oct 18, 2020

--

Hey Anupam! Congrats on the article, I think it can be quite helpful for a lot of people.

I just wanted to make a small comment regarding your point about using a 'if x in [1,2]' check.

[1,2] in this case is a list, and you could quickly optimize it by switching it to {1,2} and making it a set.

'in' operations are O(1) in sets but O(N) in lists, since with lists you need to check elements one by one to see if there's a match.

So that's just a quick tip for people out there on how to optimize their code with little effort.

Cheers for the article!

--

--

Yakko Majuri
Yakko Majuri

Written by Yakko Majuri

Programmer, writer, traveler, hitchhiker, climber, photographer. i.e. lost. (P.S. amateur at most of the above) // memoirsandrambles.substack.com

No responses yet