Skip Sorted List Construction
Documentation Index
Fetch the complete documentation index at: https://docs.sourcery.ai/llms.txt
Use this file to discover all available pages before exploring further.
Sourcery refactoring id: skip-sorted-list-construction
Section titled “Sourcery refactoring id: skip-sorted-list-construction”Description:
Section titled “Description:”Removes an unnecessary intermediate construction call for a sorted list, in
favour of the sorted builtin.
Before:
Section titled “Before:”pies = list(pie_generator())pies.sort()After:
Section titled “After:”pies = sorted(pie_generator())Explanation:
Section titled “Explanation:”It’s unnecessary to construct an intermediate list when sorting a generator, as
the sorted builtin returns a list.