def count_by(f, seq):
    """Counts numbers of occurrences of values of f()
       on elements of given sequence."""
    f = make_func(f)
    result = defaultdict(int)
    for item in seq:
        result[f(item)] += 1
    return result
Counts numbers of occurrences of values of f()
       on elements of given sequence.
funcy/seqs.py