xpathEval fails for large files

Kanch kanchana.senevirathna at gmail.com
Wed Jul 23 03:55:58 EDT 2008


On Jul 23, 11:05 am, Stefan Behnel <stefan... at behnel.de> wrote:
> Kanch wrote:
> > Original file was 18MB, and contained 288328 element attributes for
> > the particular path.
>
> You didn't say how many elements there are in total, but I wouldn't expect
> that to be a problem, unless you have very little free memory (say, way below
> 256MB). I just tried with lxml 2.1 and a 40MB XML file with 300 000 elements
> and it lets the whole Python interpreter take up some 140MB of memory in
> total. Looping over all elements by calling "list(root.iter())" takes a bit
> more than one second on my laptop. That suggests that /any/ solution involving
> lxml (or cElementTree) will do just fine for you.
>
> > I wonder whether for loop will cause a problem in iterating for 288328
> > times.
>
> You are heavily underestimating the power of the Python here.
>
> Stefan

Hi,

thanks for the help. lxml will suit my work. I have not being working
with python for that long. :)

Kanch



More information about the Python-list mailing list