Make the ragged check in DynamicTable.add_row incremental - #1561
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## dev #1561 +/- ##
=======================================
Coverage 93.15% 93.16%
=======================================
Files 41 41
Lines 10245 10259 +14
Branches 2119 2122 +3
=======================================
+ Hits 9544 9558 +14
Misses 422 422
Partials 279 279 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Update the check_ragged docval doc on add_row: the check no longer visits every element of the column. Expand the __becomes_ragged docstring with the invariant that makes comparing against the first element sound, and note that the count of checked elements tracks length only, so elements swapped in place through col.data are not detected. Link the CHANGELOG entries to the PR and trim them to the user-facing change. Sort the unittest.mock import into the stdlib block. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Contributor
|
This looks great. I made a couple minor updates to docs. Thank you @h-mayorquin ! |
rly
approved these changes
Aug 19, 2026
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.
Motivation
In the review of #1066 @rly pointed out that the ragged check iterates over every element and that he did not see a way around it, which is why
check_raggedwas added as an opt-out. This PR is an answer to that question, and to the first half of #1559. The idea is to test raggedness on-line, comparing the new element against the ones already added instead of rescanning the column. This means only asking whether the new element is the one that makes the column ragged. Once a column is marked as ragged the warning is emitted once, as that can only happen once, and the check is skipped for that column from then on. The column is rescanned once if it grew by something other than that single append, so a row added withcheck_ragged=Falseis still counted.With this improvement, the benchmark for filling a one-column table with
check_raggedat its default ofTrue, so this is what every caller ofadd_rowpays:The speedup doubles every time the table doubles, as the check went from linear per row to constant.
The biggest change is that we do not emit the warning on every row any more, which was redundant, but I think that is fine. The message is identical every time and a ragged column never becomes unragged, and the default warning filter was already collapsing the repeats by code location. What do you think? Is there something I am missing?
The
enforce_unique_idhalf of the issue is a separate change with no behavior attached to it, so I am sending it as its own PR.How to test the behavior?
The timing, which is the script from #1559 with
check_raggedleft at its default:And the warning, where the third row warns on
devand is silent here:Checklist
CHANGELOG.mdwith your changes?On the last one, the PR references #1559 but on purpose without the
Fixkeyword, as the issue covers two checks and this PR fixes one of them. It should stay open until theenforce_unique_idPR lands.