Hi,

Jens Tröger via lxml - The Python XML Toolkit schrieb am 01.04.25 um 15:22:
Oh one more: do these limits apply to serializing, e.g. tostring() (see: 
https://lxml.de/apidoc/lxml.etree.html#lxml.etree.tostring ) as well?
Jens

No, the safety limits are only a parser thing. They aim to prevent XML-bombs, i.e. externally injected data that makes the parser eat huge amounts of memory. What you do in your program's own memory is up to you, and there is no reason to prevent you from writing out whatever you built there.

BTW, if you're actually dealing with large data sets, your program may (or may not) benefit from incremental parsing and writing, instead of requiring all data in memory at one time. The parser limits still apply there (and you can use the same option "huge_tree=True" to grow them), but it can help lowering the overall memory footprint (and, thus, often the runtime) in many cases.

Stefan

_______________________________________________
lxml - The Python XML Toolkit mailing list -- lxml@python.org
To unsubscribe send an email to lxml-le...@python.org
https://mail.python.org/mailman3/lists/lxml.python.org/
Member address: arch...@mail-archive.com

Reply via email to