What is the difference between range and xrange functions in Python 2.X?

后端 未结 28 2085
深忆病人
深忆病人 2020-11-22 03:14

Apparently xrange is faster but I have no idea why it\'s faster (and no proof besides the anecdotal so far that it is faster) or what besides that is different about

28条回答
  •  后悔当初
    2020-11-22 03:56

    Additionally, if do list(xrange(...)) will be equivalent to range(...).

    So list is slow.

    Also xrange really doesn't fully finish the sequence

    So that's why its not a list, it's a xrange object

提交回复
热议问题