You can replace this block with one line:

notifications.setdefault(addr, []).append(np)