sorted() using generator expressions rather than lists

前端 未结 8 1568
梦如初夏
梦如初夏 2020-11-30 05:31

After seeing the discussion here: Python - generate the time difference I got curious. I also initially thought that a generator is faster than a list, but when it comes to

8条回答
  •  抹茶落季
    2020-11-30 06:09

    There's no way to sort a sequence without knowing all the elements of the sequence, so any generator passed to sorted() is exhausted.

提交回复
热议问题