[New-bugs-announce] [issue32425] Allow non-default XML parsers to take advantage of a _parse_whole definition in xml.etree.ElementTree.ElementTree.parse()

Gordon P. Hemsley report at bugs.python.org
Sun Dec 24 14:08:23 EST 2017


New submission from Gordon P. Hemsley <gphemsley at gphemsley.org>:

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.)

----------
components: Library (Lib), XML
messages: 309011
nosy: eli.bendersky, gphemsley, scoder
priority: normal
severity: normal
status: open
title: Allow non-default XML parsers to take advantage of a _parse_whole definition in xml.etree.ElementTree.ElementTree.parse()
type: enhancement
versions: Python 3.7

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue32425>
_______________________________________


More information about the New-bugs-announce mailing list