If I used the defaultdict instead of OrderedDict wouldn't I lose ordering so I'd have to order keys later at a performance cost or am I missing something? I don't know how much clearer using setdefault will be, but I'm fine with changing to that if that is your preference.