Sep-21-2018, 02:04 AM
The quick and dirty of it is that the
count
builtin is great for counting the presence of a single object. It does it in linear time and this is the best it gets. However if you want to count all items and use the same technique it becomes quadratic. The collections.Counter
version does basically exactly what I showed in my reply to the post Mic linked; dictionary counting all items in linear time.