Vectorize check_conditional_requirement (~127x speedup)#266
Merged
Conversation
15 tasks
SkylordA
requested changes
May 12, 2026
SkylordA
approved these changes
May 19, 2026
Merged
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.
Summary
df.apply(check_cr, axis=1)inValidator.check_conditional_requirementwith column-wise boolean masks. Per trigger column, a single vectorized(~blank) & non_default & truthymask is computed once; per required field, the OR of the masks of triggers that demand it is intersected with that field's blank mask.applyruns only over the subset of rows that actually have a missing CR field, just to build the comma-joined label string.0does not trigger, blank cells do not trigger, cells equal to the schemaDefaultdo not trigger, and a required field whose column is entirely absent is reported by its field name (matching the original).Performance
Measured against exposure (location 9501x80, account 221x41):
check_conditional_requirementTest plan
pytest tests/test_ods_package.py -v(50 passed)ods_tools checkagainst an exposure that intentionally trips conditional-requirement errors and diff the messages against the prior implementation row-by-row🤖 Generated with Claude Code