summaryrefslogtreecommitdiffstats
path: root/Lib/xml/etree/ElementTree.py
diff options
context:
space:
mode:
authorEli Bendersky <eliben@gmail.com>2012-06-15 04:42:50 (GMT)
committerEli Bendersky <eliben@gmail.com>2012-06-15 04:42:50 (GMT)
commit64d11e60f23f6b1435704adb87ebf818e5a4c0c1 (patch)
treeece3c4337e34bdb0408016b1eb38428343b75873 /Lib/xml/etree/ElementTree.py
parentfedb04a37aff9f7a2cfe746f7fc4683e74e38bf0 (diff)
downloadcpython-64d11e60f23f6b1435704adb87ebf818e5a4c0c1.zip
cpython-64d11e60f23f6b1435704adb87ebf818e5a4c0c1.tar.gz
cpython-64d11e60f23f6b1435704adb87ebf818e5a4c0c1.tar.bz2
Replace the iter/itertext methods of Element in _elementtree with true C implementations, instead of the bootstrapped Python code. In addition to being cleaner (removing the last remains of the bootstrapping code in _elementtree), this gives a 10x performance boost for iter() on large documents.
Also reorganized the tests a bit to be more robust.
Diffstat (limited to 'Lib/xml/etree/ElementTree.py')
-rw-r--r--Lib/xml/etree/ElementTree.py6
1 files changed, 1 insertions, 5 deletions
diff --git a/Lib/xml/etree/ElementTree.py b/Lib/xml/etree/ElementTree.py
index e068fc2..4776625 100644
--- a/Lib/xml/etree/ElementTree.py
+++ b/Lib/xml/etree/ElementTree.py
@@ -916,11 +916,7 @@ def _namespaces(elem, default_namespace=None):
_raise_serialization_error(qname)
# populate qname and namespaces table
- try:
- iterate = elem.iter
- except AttributeError:
- iterate = elem.getiterator # cET compatibility
- for elem in iterate():
+ for elem in elem.iter():
tag = elem.tag
if isinstance(tag, QName):
if tag.text not in qnames: