Basically, can I just use for i,v in next, instead of for i,v in pairs() in every for loop, since next is faster? Or is there a scenario where I should use pairs/ipairs
✓ ANSWER ACCEPTED
Is there any advantage of using in pairs instead of next?
1 answer
✓ Accepted answer
next is faster than pairs, but only by a tiny amount. Don't use next instead of pairs for the purpose of optimizing; use what makes the most sense to you. The reason next is slightly faster than pairs is because pairs is just a call to next. This is what pairs really looks like:
function pairs(t)
return next, t
end
Think of it this way: The atomic weight of an atom doesn't account for the mass of it's electrons; that number is just too small to mean anything. Likewise, programmers should not sacrifice more explicit code when the difference in performance is also too small to mean anything.
This discussion is preserved as it was. New answers, comments, and votes are closed.

2 comments
So what is the point of pairs....
Readability. For some people pairs is more readable, so that's what they can use. Trying to optimise your code by changing things like pairs is generally a bad idea, because it's almost always not the real bottleneck of your code.