3 ms·
In the real world you iterate, profile, and optimize
by mozman 2y ago
In the real world you iterate, profile, and optimize
- necovek 2y agoI am definitely a subscriber to not doing premature optimization, but in Python, there is a huge difference between found = searched_key in list(large_dict) vs found = searched_key in large_dict But also compare: searched_key in large_dict.keys() # O(1) and searched_value in large_dict.values() # O(n)
- carlmr 2y agoSo much this. Write code that you can reasonably expect to not be slow af, while not sacrificing readability. Then profile and optimize if necessary.