+ 2
range objects are not iterators. range is a class of a list of immutable objects. The iteration behavior of range is similar to iteration behavior of list
+ 7
belal bayrakdar ,
Snehil Pandey is right, range is not an iterator. if you create a range object and pass it to te built-in function next(), you get an errorr message like:
> TypeError: 'range' object is not an iterator
you can make the range object an iterator, if you use built-in function iter() and pass the range object to it.
+ 7
belal bayrakdar ,
i have a question according your post. what do you mean by saying:
(Is the python range() an iterator ?)
> Could I make it faster by implementing it as a generator function ?
> do you have the feeling that range is not performant, or what kind of problems or doubts do you see with range() ?
+ 1
belal bayrakdar
Yes in beginning I was also same
+ 1
No but actually both are important
+ 1
belal bayrakdar ok thanks for that I'll verify this