Re:Coding with LLMs in the summer of 2025 (an update)
by moron4hire on Sunday August 03, 2025 @11:53PM
(#44781988)
I think all you have managed to prove is A) Python is absurd, and B) you need to learn about appropriate boundaries and when to drop something.
This conversation was a lifetime ago. You couldn't reply to the original thread for a reason.
> Even assuming python's foreach loop in these cases get optimized down to a very bare for loop, the operations being performed are dominated by the looping logic itself, because the loop body is so simple.
> Each iteration of a for loop performs one index update and one termination comparison. For a simple body that is just an XOR, that's the difference between performing 5 operations (update, exit check, read array, XOR with value, XOR with index) per N elements in the one loop case versus 7 operations (update, exit, read array, XOR with value, then update, exit, XOR with index) in the two loop case. So we're looking at a 29% savings in operations.
> It gets worse if the looping structure does not optimize to a raw, most basic for loop and instead constructs some kind of lazy collection iterator generalized for all kinds of collections it could iterate over.
> The smaller the loop body, the higher the gains from optimizing the looping construct itself.
Let's test your claims
A sample run gives: And after swapping the order of the code blocks just to ensure there's nothing strange going on: So indeed we have about a 20% speedup, only in the complete opposite direction that you claimed we'd have. Perhaps it's best not to assume when talking about performance.