+ 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
21st Oct 2022, 6:14 PM
Random
Random - avatar
+ 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.
22nd Oct 2022, 6:16 PM
Lothar
Lothar - avatar
+ 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() ?
22nd Oct 2022, 6:22 PM
Lothar
Lothar - avatar
+ 1
belal bayrakdar Yes in beginning I was also same
21st Oct 2022, 6:24 PM
Random
Random - avatar
+ 1
No but actually both are important
21st Oct 2022, 6:51 PM
Random
Random - avatar
+ 1
belal bayrakdar ok thanks for that I'll verify this
22nd Oct 2022, 2:57 PM
Random
Random - avatar