We are traversing the document top-down, so we shouldn't ever need to traverse back up. In very large documents, traversing back up can be expensive. This will pass around a state that can be used to track parent information rather than ascending back up the tree.
:warning:
This is something I would consider worthy of a major version bump, as it changes the API a little bit. Anyone with currently built custom converters will encounter errors until they modify them to accept the state argument and then pass that argument to treat_children
Some performance numbers for parsing this documentbefore
unknown tag mode :pass_through
time: 0.535165
unknown tag mode :drop
time: 0.577383
unknown tag mode :bypass
time: 0.539775
after
unknown tag mode :pass_through
time: 0.080481
unknown tag mode :drop
time: 0.077927
unknown tag mode :bypass
time: 0.051546
We are traversing the document top-down, so we shouldn't ever need to traverse back up. In very large documents, traversing back up can be expensive. This will pass around a state that can be used to track parent information rather than ascending back up the tree.
:warning: This is something I would consider worthy of a major version bump, as it changes the API a little bit. Anyone with currently built custom converters will encounter errors until they modify them to accept the
state
argument and then pass that argument totreat_children
Some performance numbers for parsing this document before
after