I have many large (>35,000,000) lists of integers that will contain duplicates. I need to get a count for each integer in a list. The following code works, but seems slow. C
Replacing len(list(g)) with sum(1 for i in g) gives a 2x speedup
len(list(g))
sum(1 for i in g)