What means exactly "Memory error"?

Andrew Bennetts andrew-pythonlist at puzzling.org
Fri Apr 25 09:34:05 EDT 2003


On Thu, Apr 24, 2003 at 07:17:47PM +0200, Bo M. Maryniuck wrote:
> On Thursday 24 April 2003 17:54, Oren Tirosh wrote:
> > Try to use a streaming XML API like SAX instead of DOM. For the splitting
> > operation you describe there shouldn't be any need to store the entire file
> > in memory. You may not even need and XML parser at all - looking for the
> > HR markers could probably be done by a few regular expressions without full
> > parsing of the XML stream.
> 
> Well, I only split it by <HR> and it surely causes no problem. But for the 
> rest (a lot of changings in the document to adapt it for Zope) I probably 
> need DOM -- regular expressions outside this job.

Why can't you use SAX if all you are doing is splitting by <HR>?  Sounds
like a perfect job for SAX to me -- you just write the XML stream out to a
file as you read it in, and switch to a new file everytime you hit <HR>.
The memory requirement for this technique would be minimal.

-Andrew.






More information about the Python-list mailing list