Comment by lelanthran
20 hours ago
Why would someone put an await inside a loop?
Don't get me wrong... I believe you have seen it, I just can't understand the thought process that led to that.
In my mind, await is used when you want to use the result, not when you store it or return it.
The same can be asked about any number of things - why would someone ever not free their memory, use a dynamic allocation, not use a lock, use an orm, not use an orm.
> I just can’t understand the thought process that led to that.
Bluntly, it’s not understanding the tools and fundamentals. Your original reply assumed that it would use all cores, for example. To me that’s obviously not true but I’m sure there’s 10 things you could list off that are obvious to you but I’d get wrong -
> Your original reply assumed that it would use all cores, for example.
Sure. My original reply assumed that there wouldn't be an unnecessary `await` inserted inside a loop.
Unless I'm misunderstanding the code you posted, removing the `await` in the loop would use all cores.