REXML と ElementTree のパース時間

Ruby で REXML で2MB弱のXMLをパースしてみるとえらく待たされるように感じたのでちょっと Python2.5 の ElementTree とパースの速度を比較してみた。

% time ruby test.rb test.xml
ruby test.rb test.xml  5.67s user 0.09s system 99% cpu 5.771 total
% time python test.py test.xml
python test.py test.xml  1.44s user 0.08s system 97% cpu 1.557 total

REXML 遅っ。なぜだか WindowsRuby だとさらに倍ぐらい遅くなる。
ソースはこんな感じ。

require 'rexml/document'

ARGV.each do |arg|
   REXML::Document.new File.new(arg)
end
import sys
from xml.etree.ElementTree import parse

for arg in sys.argv[1:]:
    parse(arg)