3 ms·
It's probably best to act like more complex things are just syntax at the start. Leave the fact that something like range is just a normal function that returns
by ziml77 1y ago
It's probably best to act like more complex things are just syntax at the start. Leave the fact that something like range is just a normal function that returns a generator for later on.
Like if range was used like this:
for i in range 1 to 100:
pass
No one is going to ask how that works internally, so I don't think it's necessary to treat range(1, 100) any differently. For this usage it makes no difference if it's a generator, a list (excepting performance on large ranges), or if the local variable is incremented directly like a C-style for loop.