Message312783
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 |
|
Date |
User |
Action |
Args |
2018-02-25 08:47:15 | scoder | set | recipients:
+ scoder, Antony.Lee |
2018-02-25 08:47:15 | scoder | set | messageid: <1519548435.74.0.467229070634.issue32945@psf.upfronthosting.co.za> |
2018-02-25 08:47:15 | scoder | link | issue32945 messages |
2018-02-25 08:47:15 | scoder | create | |
|