Benchmarks and optimisations - #45
Merged
Merged
Conversation
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 0 |
| Duplication | 0 |
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
Replace the generic etree_to_dict recursive dict converter with a
single-pass Element walker that builds AboutXmlMod directly from
lxml children, eliminating the intermediate nested dict and
value_extractor calls.
Pipeline change:
Before: ET.parse -> etree_to_dict -> dict -> value_extractor ->
create_about_mod -> AboutXmlMod
After: ET.parse -> _create_about_mod_from_element -> AboutXmlMod
Microbenchmark (model construction only, 1000 mods):
41.4 us/mod -> 25.4 us/mod (1.6x faster)
Full discovery benchmark (1000 mods, incl. file I/O):
157-197ms -> 119ms parse_xml
This was
linked to
issues
Jul 29, 2026
PyXiion
added a commit
that referenced
this pull request
Jul 29, 2026
Merge main's benchmarks & optimisations (PR #45) into feat/plugins, resolving conflicts in main_window.py and justfile: - main_window: keep HEAD's simple _auto_sort wrapper around CoreContext.auto_sort() over incoming UI-level duplication - justfile: keep HEAD's build-js recipe + variadic build args, add bench recipe from main - context: log sort time in ms instead of seconds - packaging/build: add --nofollow-import-to=pytest,pygments
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Optimised mod discovery
find_about_xml— fast-path checkAbout/About.xmlwithPath.is_file()before falling back to full directory iteration (covers the vast majority of real mods)scan_mod_directory— replacePath.iterdir()withos.scandir(), returndict[Path, Path]instead oflist[Path]to cache each mod'sAbout.xmlpath during the scancreate_listed_mod_from_path— acceptabout_xml_pathparameter to skip redundantfind_about_xmlcall; callers (all three providers) pass the pre-found path from the scanOptimised topological sort
Replaced per-iteration
list.sort()+list.pop(0)in Kahn's algorithm withheapqpush/pop (O(n² log n) → O(n log n)), and flattened_build_deps_and_rev_depsfrom threeedges_of_type()calls per node to a singleoutgoing()pass with inline dispatch.Optimised XML parsing
Replaced the generic
etree_to_dictrecursive dict converter with a single-pass Element walker (_create_about_mod_from_element) that buildsAboutXmlModdirectly from lxml children, eliminating the intermediate nested dict and allvalue_extractorcalls.Pipeline change:
Before:
ET.parse→etree_to_dict→ dict →value_extractor→create_about_mod→AboutXmlModAfter:
ET.parse→_create_about_mod_from_element→AboutXmlModBenchmarks
just bench(all) orjust bench <name>(filtered)