[XML-SIG] py2exe and switching from PyXML 4Suite
Uche Ogbuji
uche.ogbuji@fourthought.com
Fri, 03 Jan 2003 23:26:39 -0700
> > >
> > > Because you're such a nice guy, I'll ditch the tease for you :-)
> >
> > You can also do these much more easily using XPath...
> >
> > from Ft.Xml import XPath
> >
> >
> > def getElementsByTagName(node,name)
> > return XPath.evaluate(node,".//" + name)
>
> I think my generator approach would be faster, but this XPath approach has the
> advantage of working in Python 2.0 and 2.1. Mine is 2.2+.
Wow. Is it ever faster. I played with this some while working on my latest
Python&XML column. Even in the smallest cases the generator approach is 4-5
times faster than the XPath approach. I tried on Bosak's old testament in XML
(900KB XML file, getting all the 23145 v elements). The generator approach
took about .82 seconds and the XPath approach took about 220 seconds. In
other words, the generator approach was almost 300 times faster.
--
Uche Ogbuji Fourthought, Inc.
http://uche.ogbuji.net http://4Suite.org http://fourthought.com
A Python & XML Companion - http://www.xml.com/pub/a/2002/12/11/py-xml.html
XML class warfare - http://www.adtmag.com/article.asp?id=6965
MusicBrainz metadata - http://www-106.ibm.com/developerworks/xml/library/x-thi
nk14.html