From: David Garamond Date: 2004-07-03T07:13:10+09:00 Subject: Re: slow method searching? Dave Thomas wrote: > > On Jul 2, 2004, at 16:56, David Garamond wrote: > >> Why does it take longer and longer for Ruby to throw NoMethodError for >> large arrays? What is going on here? This happens with hash too. > > Perhaps the time is being spent constructing the arrays? Note that I'm comparing these two: $ time ruby -e'a=(1..200000).to_a; a.classx'; # slow $ time ruby -e'a=(1..200000).to_a; b=nil; b.classx'; # fast Also I've tried this in irb and after constructing the array, each subsequent call to a.classx or a.foo (any other unknown methods) are very slow, even repeatedly. So probably the problem is not in method caching, but somehow ruby iterates or checks each element in the array? Btw, this is ruby 1.8.1 (2004-04-30) [i686-linux-gnu] -- dave