[Twisted-Python] domish.Element.__getattr__() or xpath.XPathQuery

exarkun at twistedmatrix.com exarkun at twistedmatrix.com
Sat Feb 6 10:31:26 EST 2010


On 4 Feb, 10:48 am, gabriel.rossetti at arimaz.com wrote:
>Hello everyone,
>
>I was wondering what you would recommend, accessing nodes via
>domish.Element.__getattr__()
>(e.g. el.node1.node1_1, where el is /msg) or via xpath.XPathQuery()
>(e.g. xpath.XPathQuery("/msg/node1/node1_1").queryForNodes(el)[0])?
>
>I was wondering which would be faster, the __getattr__() is O(n) (in my
>example there are 2 calls) but what about xpath.XPathQuery()?

I don't think you'll find the xpath API to be much more optimized.  I 
haven't used XMPP much, but considering the xpath implementation is 
incomplete (and afaik there's little documentation about what subset is 
supported), I'd stick with the simpler (if still terrible) 
Element.__getattr__.

Jean-Paul



More information about the Twisted-Python mailing list