I have the following snippet that extracts indices of all unique values (hashable) in a sequence-like `data` with canonical indices and store them in a dictionary as lists:

```
from collections import defaultdict
idx_lists = defaultdict(list)
for idx, ele in enumerate(data):
    idx_lists[ele].append(idx)

```

This looks like to me a quite common use case. And it happens that 90% of the execution time of my code is spent in these few lines. This part is passed through over 10000 times during execution, and `len(data)` is around 50000 to 100000 each time this is run. Number of unique elements ranges from 50 to 150 roughly.

Is there a faster way, perhaps vectorized/c-extended (e.g. `numpy` or `pandas` methods), that achieves the same thing?

Many many thanks.