This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author scoder
Recipients Antony.Lee, scoder
Date 2018-02-25.08:47:15
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1519548435.74.0.467229070634.issue32945@psf.upfronthosting.co.za>
In-reply-to
Content
sorted() *does* convert its input to a list first, and only then sorts it. It calls PySequence_List() for that, which in turn uses list_extend(), which then applies the obvious optimisation of copying input lists (and tuples) directly.

What you are seeing here is probably mostly this difference:

$ python3.7 -m timeit 'list(i for i in range(100))'
50000 loops, best of 5: 5.95 usec per loop
$ python3.7 -m timeit '[i for i in range(100)]'
100000 loops, best of 5: 3.26 usec per loop
History
Date User Action Args
2018-02-25 08:47:15scodersetrecipients: + scoder, Antony.Lee
2018-02-25 08:47:15scodersetmessageid: <1519548435.74.0.467229070634.issue32945@psf.upfronthosting.co.za>
2018-02-25 08:47:15scoderlinkissue32945 messages
2018-02-25 08:47:15scodercreate