def group_values(seq):
    """Takes a sequence of (key, value) pairs and groups values by keys."""
    result = defaultdict(list)
    for key, value in seq:
        result[key].append(value)
    return result
Takes a sequence of (key, value) pairs and groups values by keys.
funcy/seqs.py