Conversation
c4f6c6b to
4eec6c2
Compare
4eec6c2 to
9227cca
Compare
There was a problem hiding this comment.
Pull request overview
This PR optimizes the validate(...) shortcut for repeated validations by caching compiled validators and adds a check_schema flag to optionally skip schema validation, along with benchmark tooling and documentation to measure/track performance.
Changes:
- Add an internal LRU-style
ValidatorCacheforvalidate(...), plusclear_validate_cache()andcheck_schemasupport. - Introduce settings plumbing (env-driven cache size) and tests covering cache behavior and schema-check skipping.
- Add benchmark runner/comparator scripts and document how to run them.
Reviewed changes
Copilot reviewed 9 out of 11 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
openapi_schema_validator/shortcuts.py |
Implements validator caching, check_schema parameter, and cache clearing API. |
openapi_schema_validator/_caches.py |
Adds thread-safe cache implementation and schema/kwargs keying. |
openapi_schema_validator/settings.py |
Adds env-driven settings (OPENAPI_SCHEMA_VALIDATOR_VALIDATE_CACHE_MAX_SIZE) with caching/reset. |
tests/unit/test_shortcut.py |
Adds tests for check_schema=False and cache behavior/max-size behavior. |
benchmarks/run.py |
Adds benchmark runner to measure compile/validate throughput and memory. |
benchmarks/compare.py |
Adds benchmark report comparison utility with regression detection. |
benchmarks/cases.py |
Defines benchmark cases and shared schemas/registries. |
benchmarks/__init__.py |
Initializes benchmark package. |
docs/contributing.rst |
Documents benchmark usage and cache-size tuning. |
pyproject.toml |
Adds settings dependencies (pydantic, pydantic-settings). |
poetry.lock |
Locks new dependencies and updates dependency grouping metadata. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Collaborator
Author
|
@copilot open a new pull request to apply changes based on the comments in this thread |
Contributor
…port, GitHub Actions doc Co-authored-by: p1c2u <1679024+p1c2u@users.noreply.github.com>
Fix review issues: ValidationError assertion, clear_validate_cache import, GitHub Actions docs
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.
…fast path
Large performance gain for repeated
validate(...)calls on the same schema.