Why is xml.dom.minidom so slow?

Martin v. Löwis martin at v.loewis.de
Thu Jan 2 22:28:05 CET 2003


"Bjorn Pettersen" <BPettersen at NAREX.com> writes:

> All I'm doing boils down to:
> 
>   response = rf.nextResponse()
>   dom = parseString(response)
> 
> in a loop. Am I doing something wrong? 

You have to give more details. What Python version? PyXML or stock
Python? One traditional reason is that people, not knowingly, have
used PyXML xmlproc, which is a pure-Python parser, instead of Expat.

PyXML 0.8.x has a number of speed improvements for minidom-with-expat
(such as eliminating the SAX driver), and memory usage improvements
(such as interning element and attribute names).

> Is there a faster way when all I need is a traversable tree
> structure as the result?

"All I need" reads quite funny in this context, as producing a
traversable tree is one of the more expensive ways for XML
processing. There are certainly faster ways if you *don't* need a
traversable tree.

Regards,
Martin




More information about the Python-list mailing list