by sirsinsalot · 1mo ago · 0 comments
Use a defaultdict if you must have all keys optional. Using get() everywhere is buggy because it masks illegal key use.
Double lookup.
Cheaper than get() masking bugs in your code or dict generation.
But yes let's prematurely optimise for speed in a slow-by-default language by writing bug prone non-idiomatic code. OK.
Both have valid use cases. It's weird to be sarcastic about it.