Re:Python Default Dict
by earthboundkid on Wednesday May 05, 2021 @02:30PM
(#27053795)
Python has too many ways to do it:
[ Parent
| on HN ]
Re:Python Default Dict
by abcxjeb284 on Sunday May 09, 2021 @02:14AM
(#27093671)
It’s really 2 ways to do it, and the defaultdict way (I believe) would have less allocations in a deeply nested loop (since this version has to create a {} and a [] every time).
Also setdefault causes confusion for less experienced users in a way that the defaultdict format does not.