Repository navigation
Remove "lightweight" from minidom description #55588
Description
Activity
http://docs.python.org/library/xml.dom.minidom.html
presents MiniDOM as a "Lightweight DOM implementation". The word "lightweight" is easily misunderstood as meaning "efficient" or "memory friendly". MiniDOM is well known to be neither of the two.
The first paragraph then continues:
"""
xml.dom.minidom is a light-weight implementation of the Document Object Model interface. It is intended to be simpler than the full DOM and also significantly smaller.
"""Again, "smaller" can be misread as "low memory footprint", whereas it is actually supposed to refer to an incomplete DOM API implementation. And "simpler" is also clearly exaggerated when compared to the alternative ElementTree package.
I would like to see this changed and combined with a clear and visible comment that MiniDOM has very high resource profile, e.g.
"""
19.7. xml.dom.minidom — Pure Python DOM implementationxml.dom.minidom is a pure Python implementation of the Document Object Model interface, as known from other programming languages. It is intended to provide a smaller API than the full DOM.
Note, however, that MiniDOM has a very large memory footprint compared to other Python XML libraries. If you need a fast and memory friendly XML tree implementation with a vastly simpler API, use the xml.etree package instead.
"""-1. The description is factually correct - minidom *does* have a lower footprint than other Python DOM implementations (such as 4DOM).
Well, I'm not aware of many people who use 4DOM these days, and if that's what it's meant to refer to, maybe that should be made more obvious, because it currently is not at all. Even cDomlette uses only half of the memory according to
http://effbot.org/zone/celementtree.htm
When you say that the description is "factually correct", that does by no means imply that the average reader will understand how it's meant. My point is that almost everyone who reads this will draw the wrong conclusions.
Also, when you say "lower footprint", that does not yet make it "light weight" in any way. It still uses something like ten times as much memory as cElementTree or lxml in Python 2 (and likely much more than even that in Python 3), and still something like 4-5 times as much as plain Python ElementTree. That's a huge difference.
What about this phrasing then:
"""
MiniDOM has a smaller memory footprint than some of the other DOM compliant implementations for Python (such as 4DOM), but uses about 10x more memory than the faster and simpler xml.etree.cElementTree module.
"""What about this phrasing then:
""" MiniDOM has a smaller memory footprint than some of the other DOM
compliant implementations for Python (such as 4DOM), but uses about
10x more memory than the faster and simpler xml.etree.cElementTree
module. """But that's not a DOM implementation - so it would be comparing apples
and oranges.It's the tree based API most python users are parsing XML with, though. So I do not agree that it's comparing apples and oranges, not at all. It's comparing tree based XML libraries, only one of which is worth being called "light weight", and that's not the one that is currently carrying that name.
I think it's worth telling new users what they are committing to when they write code that uses MiniDOM. The documentation should allow them to understand that.
It's the tree based API most python users are parsing XML with,
though. So I do not agree that it's comparing apples and oranges, not
at all. It's comparing tree based XML libraries, only one of which is
worth being called "light weight", and that's not the one that is
currently carrying that name.If that is a real concern, I'd rather reduce the memory footprint of
minidom than put actual performance figures into the documentation
that will likely outdate over time.Notice that the documentation doesn't claim that it is a lightweight
XML library, only that it's a ligthweight DOM implementation. SAX is,
of course, even lighter-weight.If that is a real concern, I'd rather reduce the memory footprint of
minidom than put actual performance figures into the documentation
that will likely outdate over time.Personally, I do not think it's worth putting much work into MiniDOM. I'd rather deprecate it to prevent new code from being written for it, but that's just my personal opinion, and this is the wrong place to discuss that. Given the current performance characteristics, I wouldn't be surprised if there was quite some room for improvements left in the xml.dom package.
If you dislike the "10x", feel free to use "several times". I doubt that MiniDOM will ever get so much closer to cET and lxml to prove that phrasing wrong.
Notice that the documentation doesn't claim that it is a lightweight
XML library, only that it's a ligthweight DOM implementation.I imagine that you are as aware as I am that this nuance is easy to miss, especially for a new user. From my experience, it is very common for users, especially those with a Java-ish background, to confuse the terms "DOM" and "XML tree API/library". Hence my push to change the documentation.
SAX is, of course, even lighter-weight.
Not so much more light weight than cET's iterparse(), but that's getting OT here.
Stefan
Agreed with Stefan's concern.
Ok, so, what do we make of this? I proposed improvements to the wording in the documentation, which make it much clearer for users what they are buying into when they start using minidom. I still think that "factually correct" but clearly misleading documentation is not helpful and that it needs fixing. Here is an updated phrasing that I hope we can settle on:
"""
:mod:`xml.dom.minidom` --- Pure Python DOM implementation[...]
:mod:`xml.dom.minidom` is a pure Python implementation of the Document Object Model interface, as known from other programming languages. It is intended to provide a smaller and simpler API than the full W3C DOM.
Note that MiniDOM has a several times larger memory footprint than :mod:`xml.etree.ElementTree`, the light-weight Python XML library in the standard library. If you do not need a (mostly) compliant W3C DOM implementation, but a fast and memory friendly XML tree implementation with an easy to learn API, use that instead.
"""Is memory footprint something important enough to put in the doc? Ease of use is IMO more important, but then it becomes subjective..
I find a factor of an order of magnitude worth mentioning, because it prevents certain kinds of usages.
Usually we don't talk about performance in the doc, and in my personal experience I didn't notice any major difference between the different implementations (but than again I haven't used them much).
Talking about the other implementations and their advantages/disadvantages is fine, but things like "MiniDOM has a several times larger memory footprint" seems like FUD to me (see also http://docs.python.org/dev/documenting/style.html#affirmative-tone).Removing "Lightweight" and changing the first paragraph to (something like)
:mod:`xml.dom.minidom` is an implementation of the Document Object Model
interface. The API is slightly simpler than the full W3C DOM, but the
implementation has a significantly higher memory footprint than
:mod:`xml.dom.etree`.would be entirely reasonable.
(I don't think it's wrong to discuss relative memory footprints in comparison to other modules in the standard library.)
42 remaining items
Any news on this?
I’ve been unresponsive of late, sorry, but I’m still here. Will see if I have time tomorrow.
Any news on this?
I'm not sure if it's a good idea to keep bikeshedding about this for another two years. Personally, I would prefer having someone with commit rights fix this and be done with it.
Eric's last patch looks ok and parts of it went in already, so it's mostly just the heading that remains to be fixed.
Someone should go ahead and apply this. Éric, perhaps?
Sure, feel free to commit this.
New changeset c2ae1ed03853 by Ezio Melotti in branch '2.7':
bpo-11379: rephrase minidom documentation to use the term "minimal" instead of "lightweight". Patch by Éric Araujo.
http://hg.python.org/cpython/rev/c2ae1ed03853New changeset b9c0e050c935 by Ezio Melotti in branch '3.2':
bpo-11379: rephrase minidom documentation to use the term "minimal" instead of "lightweight". Patch by Éric Araujo.
http://hg.python.org/cpython/rev/b9c0e050c935New changeset 8ff512910338 by Ezio Melotti in branch '3.3':
bpo-11379: merge with 3.2.
http://hg.python.org/cpython/rev/8ff512910338New changeset 9a0cd5363c2a by Ezio Melotti in branch 'default':
bpo-11379: merge with 3.3.
http://hg.python.org/cpython/rev/9a0cd5363c2aFixed, thanks for the patch!
- addedtype-featureA feature request or enhancementA feature request or enhancementand removedperformancePerformance or resource usagePerformance or resource usage
on Jan 22, 2013 New changeset 39ea24aaf0e7 by Antoine Pitrou in branch '2.7':
s/lightweight/minimal/, as per issue bpo-11379.
http://hg.python.org/cpython/rev/39ea24aaf0e7New changeset b63258b6eb4d by Antoine Pitrou in branch '3.3':
s/lightweight/minimal/, as per issue bpo-11379.
http://hg.python.org/cpython/rev/b63258b6eb4dNew changeset d659e7761d59 by Antoine Pitrou in branch 'default':
s/lightweight/minimal/, as per issue bpo-11379.
http://hg.python.org/cpython/rev/d659e7761d59
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields: