pydantic-core
pydantic-core copied to clipboard
Optimized traversal of schema tree for schema cleaning (`GenerateSchema.clean_schema`)
Change Summary
Adds schema tree traversal which gathers necessary schema nodes and information for schema inlining and discriminator handling. Schema tree traversal is done in a single pass gathering the needed information. This is used in GenerateSchema.clean_schema
handling. Required for PR https://github.com/pydantic/pydantic/pull/10655 This makes schema cleaning much more efficient where the biggest bottleneck has been the Python side tree traversal. This especially with lots of models or deep models.
Related issue number
See above Pydantic side PR.
Checklist
- [x] Unit tests for the changes exist
- [x] Documentation reflects the changes where applicable
- [x] Pydantic tests pass with this
pydantic-core
(except for expected changes) - [x] My PR is ready to review, please add a comment including the phrase "please review" to assign reviewers
Selected Reviewer: @sydney-runkle