On Oct 7, 2010, at 15:11 , Intransition wrote:

> However, if I am really concerned about squeezing out every bit of
> speed, I would do:
>=20
>  class X
>    def initialize
>      @f =3D ( do_some_calc_or_lookup )
>    end
>    def f
>      @f
>    end
>  end

There is a damn good reason why lazy initializing exists in the first =
place, and it invalidates your statement above.

If you were __really__ concerned about squeezing out every bit of speed, =
you'd profile the code to see how it is used. If #f isn't being called =
in a tight loop, or isn't even being called much at all, then you might =
be spending more time running initialize than you would have doing the =
lazy initialize. You'll never know that mentarbating over =
micro-benchmarks.