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.
This commit is contained in:
Eli Bendersky 2012-06-15 07:42:50 +03:00
parent fedb04a37a
commit 64d11e60f2
4 changed files with 414 additions and 229 deletions

View file

@ -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: