Shared publicly  - 
 
A project I'm working on needs to be able to store counts of how frequently certain combinations of a set of values occur. The most elegant way to do this in newer Python versions is to store the input values as a namedtuple and keep track of the number of occurrences using the collections.Counter class. But under both CPython and PyPy, this turned out to be slower than other methods.

Turns out the fastest method is to use a defaultdict keyed by regular tuples (and to use PyPy). The linked gist shows the results of my experiments.
1
Add a comment...