Skip Sorted List Construction¶
Sourcery refactoring id: skip-sorted-list-construction
¶
Description:¶
Removes an unnecessary intermediate construction call for a sorted list, in
favour of the sorted
builtin.
Before:¶
pies = list(pie_generator())
pies.sort()
After:¶
pies = sorted(pie_generator())
Explanation:¶
It's unnecessary to construct an intermediate list when sorting a generator, as
the sorted
builtin returns a list.