From mail at jdborg.com Wed Jun 13 19:39:36 2012 From: mail at jdborg.com (=?UTF-8?B?Sm9lIEJvcsSh?=) Date: Wed, 13 Jun 2012 18:39:36 +0100 Subject: [xml-sig] _get_elements_by_tagName_helper taking resources Message-ID: I'm running a script with 2.7 that deals with some heavy XML files. I'm trying to speed it up best I can; using cProfile I've seen what's taking all the time. It's the function _get_elements_by_tagName_helper. Can anyone tell me where this is called and if I can improve its runtime speed? Thanks, Joseph David Bor? http://www.jdborg.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From stefan_ml at behnel.de Wed Jun 13 20:35:37 2012 From: stefan_ml at behnel.de (Stefan Behnel) Date: Wed, 13 Jun 2012 20:35:37 +0200 Subject: [xml-sig] _get_elements_by_tagName_helper taking resources In-Reply-To: References: Message-ID: <4FD8DD79.4090609@behnel.de> Joe Bor?, 13.06.2012 19:39: > I'm running a script with 2.7 that deals with some heavy XML files. I'm > trying to speed it up best I can; using cProfile I've seen what's taking > all the time. It's the function _get_elements_by_tagName_helper. Can > anyone tell me where this is called and if I can improve its runtime speed? I assume you are using minidom? My (biased) advice would be to switch to lxml. It's substantially faster than mindom in basically all regards. Alternative, if that suits your needs, use the xml.etree.cElementTree package in the stdlib, which is also substantially faster but less capable. Stefan From mail at jdborg.com Thu Jun 14 14:59:43 2012 From: mail at jdborg.com (=?UTF-8?B?Sm9lIEJvcsSh?=) Date: Thu, 14 Jun 2012 13:59:43 +0100 Subject: [xml-sig] _get_elements_by_tagName_helper taking resources In-Reply-To: <4FD8DD79.4090609@behnel.de> References: <4FD8DD79.4090609@behnel.de> Message-ID: Thanks Stefan, It was taking 30 seconds, now taking 3! Regards, Joseph David Bor? http://www.jdborg.com On 13 June 2012 19:35, Stefan Behnel wrote: > Joe Bor?, 13.06.2012 19:39: > > I'm running a script with 2.7 that deals with some heavy XML files. I'm > > trying to speed it up best I can; using cProfile I've seen what's taking > > all the time. It's the function _get_elements_by_tagName_helper. Can > > anyone tell me where this is called and if I can improve its runtime > speed? > > I assume you are using minidom? My (biased) advice would be to switch to > lxml. It's substantially faster than mindom in basically all regards. > Alternative, if that suits your needs, use the xml.etree.cElementTree > package in the stdlib, which is also substantially faster but less capable. > > Stefan > _______________________________________________ > xml-sig mailing list > xml-sig at python.org > http://mail.python.org/mailman/listinfo/xml-sig > -------------- next part -------------- An HTML attachment was scrubbed... URL: