Creating a "dictionary of sets"

from collections import defaultdict
mydict = defaultdict(set)
mydict["key1"] |= {'1484', '1487', '1488'}

Iteration is just like the normal dict.


Using dict.setdefault() to create the key if it doesn't exist, and initialising it with an empty set:

store = {}
for key, value in yoursource:
    store.setdefault(key, set()).add(value)

I'm not going to benchmark this but in my experience native dicts are faster

store = {}
for key, value in yoursource:
    try:
        store[key].add(value)
    except KeyError:
        store[key] = {value}