mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00
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:
parent
fedb04a37a
commit
64d11e60f2
4 changed files with 414 additions and 229 deletions
|
@ -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:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue