From: Roger Pack Date: 2009-12-23T09:40:34+09:00 Subject: Re: [ANN] google_hash 0.1.1 -- it has a #each! > Or basically a better hash, either one that is faster or more space > efficient than ruby's default. To attempt this we wrap the google > sparse and dense hashes [1]. As a note, also released 0.2.1 recently. Changes: Added RubyToRuby Hash [drop in replacement for the default hash]. added #keys and #values and #keys_combination_2 methods. In general the :int => Ruby hashes are much faster than Ruby's hash lookups. The RubyToRuby Hash is a bit slower for insertion/lookup and far faster for #each than the default hash. new usage: a = GoogleHashDenseRubyToRuby.new # or GoogleHash.new b = GoogleHashDenseLongToRuby.new # a hash that is only :int => Ruby b = GoogleHashSparseLongToRuby.new # a hash that is only :int => Ruby, and uses less memory [Sparse] a[3] = 4 b[4] = 'abc' b['abc'.hash] = 'some complex object' a.each{|k, v| ... } a.keys => Array a.values => Array speed comparison: 1.9 mingw results http://pastie.org/752318 1.9.2 linux: http://pastie.org/752333 Enjoy. -r -- Posted via http://www.ruby-forum.com/.