Implement an alternative to the LXML backend #554
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This could prove to be a viable alternative to #217. Initial experimentation has shown promising results with almost 50% reduction in memory use when using a specialized, custom parser built on top of quick-xml even in a still relatively naive implementation, where the main idea is to deduplicate tag and attribute names in memory (using a temporary
HashMap
to storeArc<(Option<String>, String)>
over directly using the parsed-out(Option<String>, String)
on the Rust side, but the same should hold true for the Python equivalents) — and there's probably still a lot of room for further optimizations.This might still prove to be completely non-viable depending on the actual feature set that we'd have to reimplement, but so far the only bigger issues I've found are a few simple XPaths (which should be straight-forward to implement without an XPath engine) and the
MelodyModel.find_references()
function, which delegates to C code via an XPath query in order to actually become usable in terms of performance (if I'm not mistaken, runtime went down by at least 2-3 orders of magnitude).