Issue 32425: Allow non-default XML parsers to take advantage of a _parse_whole definition in xml.etree.ElementTree.ElementTree.parse() (original) (raw)
Currently, ElementTree.parse() in xml.etree.ElementTree only invokes _parse_whole() on the parser if no parser is specified and it falls back to the built-in XMLParser.
This has two drawbacks:
- If the built-in XMLParser is specified explicitly, it does not get the advantage of using its _parse_whole() method.
- If another XML parser is specified, it does not have the option to define a _parse_whole() method.
In both cases, the parser parses in chunks (of 16 KiB), which is potentially slower.
I propose allowing any parser to take advantage of _parse_whole() if it has defined such a method. (This would also have the benefit of eliminating some minor code duplication--two return branches could become one.)