✨ feat(tree): bulk wrap_children and wrap_siblings#254
Draft
gaborbernat wants to merge 2 commits into
Draft
Conversation
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.
Adds two bulk-wrap structural edits, the in-place counterpart of pyquery's
.wrap_all:Element.wrap_children(wrapper)moves every child of an element into one new wrapper element and makes the wrapper the sole child.Node.wrap_siblings(wrapper, *, until=None)wraps a node and the contiguous run of siblings after it (through anuntilnode, or to the last sibling whenuntilisNone) into one new element, placed where the run began.Both take a fresh wrapper element and return it, mirroring
Node.wrap, and run entirely in the C core under the per-tree critical section.Free-threading
The run and parent are resolved and rewired in pure C under the per-tree lock; the parent is read inside the critical section (not before it) so a concurrent move that relinks the node cannot stale it. Covered by a new stress test under
pytest-run-parallel.Validation
-e 3.14(llvm-cov): 100% line + branch,tree_type.c3366/3366tree_type.c100% line (aggregate noise on other files ignored)-e fix,-e type,-e docs,-e 3.14tgreencloses #247