xml.dom.minidom memory usage

Bruno Desthuilliers bdesth.quelquechose at free.quelquepart.fr
Thu Feb 1 16:52:15 EST 2007


Dan a écrit :
> I'm using python's xml.dom.minidom module to generate xml files, and
> I'm running into memory problems. The xml files I'm trying to create
> are relatively flat, with one root node which may have millions of
> direct child nodes.

Woops ! You're looking for trouble.

> 
> So, my questions are (1) am I doing something dumb in the script

Yes : using minidom !-)

> that
> stops python from collecting temp garbage? 

That's not the problem. The problem is with how xml dom APIs work: they 
build the whole damn tree in memory.

> (2) If not, is there
> another reasonable module to generate xml (as opposed to parsing it),
> or should I just implement my own xml generation solution?

You should have a look at Genshi:
http://genshi.edgewall.org/




More information about the Python-list mailing list