Dave Baldwin wrote in post #987924:
> set to
>        Array.new(2){ Array.new(1){ Array.new( 20, rand(1) ) } }
>
> I get 3.75 seconds
>
> set to
>        # h1[ "#{a}.#{b}.#{c}.#{d}" ] = Array.new(2){ Array.new(1){
> Array.new( 20, rand(1) ) } }
>
> I get 0.47 seconds

Try these too:

    h1[ "#{a}.#{b}.#{c}.#{d}".freeze ] = 3

    h1[ "#{a}.#{b}.#{c}.#{d}".freeze ] = Array.new etc

It's a foible of Ruby that if you use a String as a hash key, it is 
dup'd and frozen - unless it was frozen already, which is what the above 
does.

The other thing to beware of is YAML - try using Marshal instead as a 
comparison, because YAML might not be very efficient when dealing with 
very large data structures. I think you said you needed a human-editable 
form, but this would rule out YAML as the source of the problem.

If it is, then you can look at alternative YAML libraries, or at JSON.

-- 
Posted via http://www.ruby-forum.com/.