Hacker News new | ask | show | jobs
by cirrus3 701 days ago
I wouldn't even really call that loop example an "optimization", it is just the obviously more efficient implementation.
1 comments

Yet I see it constantly. That pattern of `for foo in whatever: for bar in foo` is everywhere. People don't even think about it... They just write the looping part then start thinking about the logic below. It's such a common thing I'm surprised compilers and interpreters don't just optimize it away :shrug: