If you want to get the counts ignoring order, use a frozenset
with Counter:
from collections import Counter
print(Counter(map(frozenset, y)))
Using the tuples
from another answer:
In [9]: len(tuples)
Out[9]: 500000
In [10]: timeit Counter(map(frozenset, tuples))
1 loops, best of 3: 582 ms per loop
Using a frozenset will mean (1, 2)
and (2,1)
will be considered the same:
In [12]: y = [(1, 2), (2, 3), (1, 2), (5, 6),(2, 1),(6,5)]
In [13]: from collections import Counter
In [14]:
In [14]: print(Counter(map(frozenset, y)))
Counter({frozenset({1, 2}): 3, frozenset({5, 6}): 2, frozenset({2, 3}): 1})
If you apply the same logic using multiprocessing, it will obviously be considerably faster, even without it beats what has been provided using multiprocessing.