Ipairs
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Re: Ipairs
Thank you, that explains quite a bit.
"your actions cause me to infer your ego is the size of three houses" -finley
Re: Ipairs
Using pairs is slightly faster than ipairs. Indexing is quite a bit faster than both. There was a discussion over this recently with a nice graph illustrating the speeds of the different iterating methods, but I can't find the thread now.T-Bone wrote: Are these two methods equally fast by the way?
Re: Ipairs
Here's a link to the exciting graphs: http://www.facepunch.com/threads/875909 ... and-ipairs
Re: Ipairs
Also, "arrays", or tables that are number-ordered like {"item", "another item", "you get the idea"} are called "sequences" in Lua. (according to the Lua 5.2 documentation)
Re: Ipairs
... wait, there were arguments over which of pairs or ipairs were faster? what? this shouldn't be an issue in the first place since they aren't really interchangeable to begin withpudding wrote:Here's a link to the exciting graphs: http://www.facepunch.com/threads/875909 ... and-ipairs
the only one i remember hearing about is ipairs vs a numeric for, the latter of which is faster mainly because it doesn't have a per-iteration function call
- kikito
- Inner party member
- Posts: 3153
- Joined: Sat Oct 03, 2009 5:22 pm
- Location: Madrid, Spain
- Contact:
Re: Ipairs
The article pointed out by pudding states that pairs is faster under very specific circumstances - tables with more than 15k elements. That's the edge case, not the norm; you usually have less than that. Ipairs is the fastest one in general.Kadoba wrote:Using pairs is slightly faster than ipairs.
When I write def I mean function.
- Robin
- The Omniscient
- Posts: 6506
- Joined: Fri Feb 20, 2009 4:29 pm
- Location: The Netherlands
- Contact:
Re: Ipairs
Still, why would you care either way? They do what they're supposed to do, and they're still much faster than anything in, say, Ruby.
This is not meant as a slight against Ruby: it usually also gets the job done, in terms of speed.
This is not meant as a slight against Ruby: it usually also gets the job done, in terms of speed.
Help us help you: attach a .love.
- kikito
- Inner party member
- Posts: 3153
- Joined: Sat Oct 03, 2009 5:22 pm
- Location: Madrid, Spain
- Contact:
Re: Ipairs
you are absolutely right. Most of the time, these small differences don't matter.
Nevertheless, I was curious about the situation: it isn't intuitive that pairs is faster, even if only in some cases
Nevertheless, I was curious about the situation: it isn't intuitive that pairs is faster, even if only in some cases
When I write def I mean function.
Who is online
Users browsing this forum: Amazon [Bot] and 3 guests