>>>>> "M" == Mike Stok <mike / stok.co.uk> writes:

M>          # constructing data outside of the loop saves some time...

 It's normal, you have seen the difference between a local and a dynamic
variable. 

 When data is outside of the "loop" it's a local variable and you have only
one "instance".

 When the first appareance of data is in a "do ... end" it's a dynamic
variable and ruby create a new "instance" for each iteration.

 When you have many iterations (100000), you can see the effect of the GC

 More ruby don't have the same algorithm to find a local variable or a
 dynamic variable and it's always a little faster with a local
 variable. The algorithm to find a local variable can be seen similar to
 the gestion of "my" variables in a P language : this is resolved at
 compile time and ruby store in the node the index of the variable (the
 local variables are in an C array nad are allocated when ruby enter in the
 def) 



Guy Decoux