Benefits of xml.dom.minidom?

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Benefits of xml.dom.minidom?

John Gordon-2
I recently inherited some code that uses xml.dom.minidom to build a large
XML document, and I noticed that it is quite slow and uses a ton of memory.

I converted the same code to use lxml.etree and it is much faster and
uses not nearly so much memory.

Why is minidom so hungry for resources?  What is it doing with all that
memory and CPU?

--
John Gordon                   A is for Amy, who fell down the stairs
[hidden email]              B is for Basil, assaulted by bears
                                -- Edward Gorey, "The Gashlycrumb Tinies"

--
http://mail.python.org/mailman/listinfo/python-list
Reply | Threaded
Open this post in threaded view
|

Re: Benefits of xml.dom.minidom?

hidura

I use minidom all the time and i don' t have that problem could you describe more of the process ?
El oct 20, 2011 5:53 p.m., "John Gordon" <[hidden email]> escribió:
>
> I recently inherited some code that uses xml.dom.minidom to build a large
> XML document, and I noticed that it is quite slow and uses a ton of memory.
>
> I converted the same code to use lxml.etree and it is much faster and
> uses not nearly so much memory.
>
> Why is minidom so hungry for resources?  What is it doing with all that
> memory and CPU?
>
> --
> John Gordon                   A is for Amy, who fell down the stairs
> [hidden email]              B is for Basil, assaulted by bears
>                                -- Edward Gorey, "The Gashlycrumb Tinies"
>
> --
> http://mail.python.org/mailman/listinfo/python-list


--
http://mail.python.org/mailman/listinfo/python-list
Reply | Threaded
Open this post in threaded view
|

Re: Benefits of xml.dom.minidom?

Stefan Behnel-3
In reply to this post by John Gordon-2
John Gordon, 20.10.2011 19:46:
> I recently inherited some code that uses xml.dom.minidom to build a large
> XML document, and I noticed that it is quite slow and uses a ton of memory.
>
> I converted the same code to use lxml.etree and it is much faster and
> uses not nearly so much memory.
>
> Why is minidom so hungry for resources?  What is it doing with all that
> memory and CPU?

Not much. It's memory hungry because it builds a tree from rather heavy XML
objects and is neither optimised for speed nor for a low memory footprint.
Its main purpose is to be (mostly) W3C DOM compatible. It's also been in
the standard library for quite a bit longer than ElementTree, and predates
lxml by years. That's the most likely reason why your original script was
written using minidom.

In a way, it's unfair to compare minidom with lxml.etree (or cElementTree,
for that purpose), as the latter two were specifically designed for high
performance and a much simpler API.

Stefan

--
http://mail.python.org/mailman/listinfo/python-list