Name
xrange
Synopsis
xrange([start
,]stop
[,step
=1])
Returns a sequence object whose items are integers in arithmetic
progression. The arguments are the same as for
range
, covered in this section. While
range
creates and returns a normal list object,
xrange
returns a sequence object of a special
type, meant only for use in a for
statement.
xrange
consumes less memory than
range
for this specific, frequent use, although
the performance difference is usually small.
Get Python in a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.