From: murphy Date: 2007-07-06T20:13:00+09:00 Subject: Optimizing Symbol#to_proc Greetings to the list! I think Symbol#to_proc will get used a lot in the future, and since it's ususally applied to Enumerations, the proc gets called a lot. The implementation is much faster than the old Ruby code versions, but compared to a hand-written inline block, it's still slow: Benchmark.bm(20) do |bm| a = Array.new(1000, nil) bm.report 'to_proc' do 1000.times do a.each(&:nil?) end end bm.report 'block' do 1000.times do a.each { |x| x.nil? } end end end # >> user system total real # >> to_proc 0.620000 0.000000 0.620000 ( 0.624540) # >> block 0.250000 0.010000 0.260000 ( 0.253732) (Ruby 1.9 from today, MacBook, OSX) Maybe this is a good place for more optimization, or even VM magic? [murphy]