Use dict setdefault instead of reimplementing it
Use dict setdefault instead of reimplementing it

It's clearer in intent, and slightly faster.

$ python -m timeit 'd = {}; d.setdefault("a", 12)'
5000000 loops, best of 5: 96.2 nsec per loop
$ python -m timeit 'd = {}; d["a"] = d.get("a", 12)'
2000000 loops, best of 5: 107 nsec per loop

stefanfoulis/django-phonenumber-field