Skip to content

✨ feat(tree): bulk wrap_children and wrap_siblings#254

Draft
gaborbernat wants to merge 2 commits into
tox-dev:mainfrom
gaborbernat:feat/wrap-all
Draft

✨ feat(tree): bulk wrap_children and wrap_siblings#254
gaborbernat wants to merge 2 commits into
tox-dev:mainfrom
gaborbernat:feat/wrap-all

Conversation

@gaborbernat

Copy link
Copy Markdown
Member

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 an until node, or to the last sibling when until is None) 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.c 3366/3366
  • gcc-16 cross-check: tree_type.c 100% line (aggregate noise on other files ignored)
  • -e fix, -e type, -e docs, -e 3.14t green
  • Freethread stress: 200 iterations of the module + 300 of the bulk-wrap test in parallel, all clean

closes #247

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bulk DOM wrap: wrap_children / wrap_siblings (pyquery wrap_all)

1 participant