et_xmlfile documentation

et_xmlfile is a low memory streaming XML generator developed for compatibility with lxml.etree.xmlfile where this is not available. It is pure Python and about twice as slow than lxml or other solutions.

Note on performance

There is one area where an optimisation for lxml will negatively affect the performance of et_xmfile: when using the .element() method on an xmlfile context manager. It is recommended not to use this, though the method is provided for code compatibility.

Sample code:

from io import BytesIO
from xml.etree.ElementTree import Element

from et_xmlfile import xmlfile

out = BytesIO()
with xmlfile(out) as xf:
    el = Element("root")
    xf.write(el) # write the XML straight to the file-like object

assert out.getvalue() == b"<root />"

API Documentation