From: Eric Hodel Date: 2006-12-28T07:09:55+09:00 Subject: Re: Contest: fastet way to redefine a method On Dec 27, 2006, at 08:59, Pit Capitain wrote: > Dan Berger's recent thread about using UnboundMethod#bind to > redefine an existing method reminded me of a problem I still have: > > What is the fastest way to redefine an existing method? > > With "fast" I don't mean the process of redefining the method, but > the time it takes to actually call the new implementation. > > With "redefining an existing method" I mean changing the > implementation of an existing method so that in the new > implementation it is possible to call the old one and use its > return value. > > I've seen many different techniques in the past here on ruby-talk, > but I haven't looked at the tradeoffs. I promise to write a page on > the ruby garden wiki with the results. I already did this: http://blog.segment7.net/articles/2006/03/06/attr-vs-method-vs- define_method You can probably match def for speed by using one of the eval methods. -- Eric Hodel - drbrain@segment7.net - http://blog.segment7.net I LIT YOUR GEM ON FIRE!