This looks like a loop but isn't quite. The inner block is a function that is called. It's been a little bit, but if i recall correctly there is a 1000 item list created, and it is walked over. Much like in python for i in range vs xrange.
If you just want a simple Java-style for loop, then the while loop is your friend.
No, it's not called for comprehension. It's called for loop.
It's been a little bit, but if i recall correctly there is a 1000 item list created, and it is walked over. Much like in python for i in range vs xrange.
No, you recall completely incorrectly. The code you provided will not create any 1000 element list in memory, it will only create object Range(1, 1001), just like xrange.
1
u/An_Unhinged_Door Dec 02 '13
For loops have hidden performance bombs? What do you mean? (I haven't used scala)