nitpick: could you use {} instead of dict? it is more conventional (and happens to be faster)