[Python-Dev] ElementTree in stdlib

Walter Dörwald walter at livinglogic.de
Tue Dec 13 10:56:33 CET 2005


Guido van Rossum wrote:

> On 12/12/05, skip at pobox.com <skip at pobox.com> wrote:
> 
>>    Martin> It's difficult to establish precise numbers, but I would expect
>>    Martin> that most readers of xml-sig are well aware of how DOM and SAX
>>    Martin> work, perhaps even better than ElementTree.
>>
>>Perhaps the corollary is that people who are not xml-sig readers will likely
>>be put off by DOM and SAX.  I couldn't tell you what they do, just that they
>>were Too Hard (tm) for me to bother with XML in most situations.  Then
>>ElementTree came along.
> 
> It seems pretty clear why DOM isn't Pythonic: it doesn't use Python's
> standard APIs for things that conceptually are "just" lists and dicts,
> or at least sequences and mappings. Also, the memory footprint is a
> bit outlandish.
> 
> I don't think that SAX is unpythonic, but it's pretty low-level and
> mostly of use to people writing higher-level XML parsers (my parsexml
> module uses it).

Having to define classes that conform to a certain API and registering 
instances of those classes as callbacks with the parser doesn't look 
that pythonic to me. An iterator API seems much more pythonic.

Then again, pythonic is whatever you say that it is. ;)

Bye,
    Walter Dörwald


More information about the Python-Dev mailing list