Re: xml.dom.minidom memory usage

2007-02-18 Thread Stefan Behnel
Dan wrote: I'm using python's xml.dom.minidom module to generate xml files, and I'm running into memory problems. Then take a look at cElementTree. It's part of Python 2.5 and is available as a separate module for Python 2.4. It's fast, has a very low memory profile and if you ever decide to

xml.dom.minidom memory usage

2007-02-01 Thread Dan
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. Here's an example script: #!/usr/bin/env python import xml.dom.minidom

Re: xml.dom.minidom memory usage

2007-02-01 Thread Jonathan Curran
Dan, The DOM (Document Object Model) is such that it loads all the elements of the XML document into memory before you can do anything with it. With your file containing millions of child nodes this will eat up as much memory as you have. A solution to this is to use the SAX method of

Re: xml.dom.minidom memory usage

2007-02-01 Thread Jonathan Curran
Dan, I jumped the gun and didn't read your entire post. I ended up skipping a lot of parts, especially where you say that you are creating a document (for some reason I thought you were reading it). I looked at the setAttribute function and thought: ah he's writing it out.

Re: xml.dom.minidom memory usage

2007-02-01 Thread Dan
On Feb 1, 3:12 pm, Jonathan Curran [EMAIL PROTECTED] wrote: Dan, The DOM (Document Object Model) is such that it loads all the elements of the XML document into memory before you can do anything with it. With your file containing millions of child nodes this will eat up as much

Re: xml.dom.minidom memory usage

2007-02-01 Thread Bruno Desthuilliers
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

Re: xml.dom.minidom memory usage

2007-02-01 Thread Jonathan Curran
Dan, Take a look at http://www.xml.com/pub/a/2003/03/12/py-xml.html. It's a starting point to output XML data via use of SAX. Bruno also mentioned Genshi. I haven't used Genshi myself, but it'd be worth it to take a look at what it has to offer. - Jonathan --