The idea is that referencing the `append` method in the for grouping loop, i.e. doing
d[key(item)].append(item)
takes more time than rebuilding the _rv_ groups dictionary with lists instead of `append` methods.
Of course, a benchmark should be run and see how much longer the input sequence needs to be than the resulting groups, for this to happen.
The idea is that referencing the `append` method in the for grouping loop, i.e. doing
takes more time than rebuilding the _rv_ groups dictionary with lists instead of `append` methods. Of course, a benchmark should be run and see how much longer the input sequence needs to be than the resulting groups, for this to happen.[1]: https://wiki.python.org/moin/PythonSpeed/PerformanceTips#Avo......