Repository navigation
Conversation
Cache clean names within each blob and recognize unchanged ASCII identifiers before constructing nodes. Reuse the empty-name constructor path for cached names and pass ordinary node fields positionally, while preserving keyword construction and name cleaning for subclasses. Warmed tests/test_main.py::test_save: 91.7 ms -> 35.0 ms per call (median of five standard-library timeit repeats of 30 calls). Three frozen-harness ratios: 0.414, 0.397, 0.425. Native tests: 44 passed; full Ruff lint and formatting passed. Co-Authored-By: Aiden <aiden@weco.ai>
This branch has not been deployed
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.
TL;DR
TypeTreeNode.parse_blobon the repository'stests/test_main.py::test_saveload/save/reload workload.timeit: median of five repeats of 30 calls, after an untimed warm-up, on an isolated core.test_savecall (2.6x faster). Three frozen-harness candidate/baseline ratios were 0.414, 0.397, and 0.425.Problem and change
parse_blobconstructs a node for every binary type-tree entry. The constructor derives_clean_nameeach time; the compiled implementation constructs two regular expressions even for names that remain unchanged. Repeated names therefore repeat expensive work.This change keeps a clean-name cache local to each parse. Plain ASCII identifiers other than
passandfromalready have their final clean name. Other names use the first real node's computed value. When that value is available, the node uses the inexpensive empty-name constructor path and then receives its original name and cached clean name. Ordinary nodes use positional construction with a fresh child list; subclasses retain keyword construction and their own name-cleaning behavior. The change is confined toparse_bloband works with both UnityPyBoost and the attrs fallback.Measurements
test_save, median of five 30-call repeatstest_save, median of three pytest call durationsMeasurements used Python 3.12.13 and isolated benchmark cores. The warmed repository benchmark used:
The reported result is the median of the five per-repeat per-call times, rather than timeit's default best-repeat summary. Fresh-process timings came from pytest's JUnit call-only durations, alternating baseline/candidate order, and include first-call initialization; they are reported separately from the warmed speedup.
The frozen evaluator mirrors the sample load/save/reload cycle and also parses recorded blobs with the attrs fallback. Each score uses nine interleaved baseline/candidate pairs with shuffled sample order and two workload repetitions. It checks saved-byte hashes and every node field against an independent baseline oracle. The observed relative IQRs were 6.3%, 9.7%, and 6.1%, below its 20% limit; all three time ratios are below the required 0.80 threshold.
Validation
python -m pytest -q -p no:cacheprovider tests/test_typetree.py tests/test_main.py tests/test_UnityVersion.py tests/test_astc.py: 44 passed in 3.26s.ruff checkandruff format --check: passed, 92 files already formatted (Ruff 0.17.3).AI assistance and provenance
Codex (gpt-6.1-sol) generated candidates tracked with Weco Observe. The selected source is the exact recorded step 5 of run
7e8dfc76-13b2-4288-817a-fb9410034f98, which contains 14 distinct valid non-baseline candidates. Candidate counts are from this run alone. Step 5 was chosen for its smaller change; the faster recorded step 10 also changes string decoding and tree assembly, for a measured gain within the harness noise limit relative to step 5.Validation and source review were automated. Three preliminary rescore attempts were rejected because lint had left a
.ruff_cachedirectory in the test tree; their results were retained. Moving that generated cache outside the tree left source bytes unchanged, and the three clean-tree scores above then passed.Weco share link: https://dashboard.weco.ai/share/WjmBTYxucv7EwrkZmcRRZCwXLqXRvmcv