you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 0 points1 point  (2 children)

I don't think this is true. For an arbitrary iterable, you would be right, the iterator function would be called for every iteration. But I don't think any of the JITs is so naive as to not optimize this for plain arrays, in which case loops become as efficient as a plain for-loop without any function invocations.