Skip to content

Conversation

@davidhewitt
Copy link
Contributor

Change Summary

Imported from pydantic/pydantic-core#1620

The idea here is that JSON data doesn't need to use map lookup, we can instead iterate through the found data. I build a lookup tree which handles this.

The code is almost right, needs a lot of cleanup. There are still some very minor differences due to handling of alias & in error messages, I believe these are resolvable.

Related issue number

This is going to be necessary for the "iteration" validation in #10032

Checklist

  • The pull request title is a good summary of the changes - it will be used in the changelog
  • Unit tests for the changes exist
  • Tests pass on CI
  • Documentation reflects the changes where applicable
  • My PR is ready to review, please add a comment including the phrase "please review" to assign reviewers

@github-actions github-actions bot added the relnotes-fix Used for bugfixes. label Nov 19, 2025
@davidhewitt davidhewitt added relnotes-performance Used for performance improvements. and removed relnotes-fix Used for bugfixes. labels Nov 19, 2025
@codspeed-hq
Copy link

codspeed-hq bot commented Nov 19, 2025

CodSpeed Performance Report

Merging #12550 will degrade performances by 9.77%

Comparing dh/validate-by-iteration (c8387cc) with main (b834e98)

Summary

⚡ 1 improvement
❌ 1 regression
✅ 209 untouched

⚠️ Please fix the performance issues or acknowledge them on CodSpeed.

Benchmarks breakdown

Benchmark BASE HEAD Change
test_build_schema 274 µs 303.6 µs -9.77%
test_core_json_fs 174.6 µs 123.8 µs +40.95%

@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Nov 21, 2025

Deploying pydantic-docs with  Cloudflare Pages  Cloudflare Pages

Latest commit: c8387cc
Status: ✅  Deploy successful!
Preview URL: https://a10d7aa4.pydantic-docs.pages.dev
Branch Preview URL: https://dh-validate-by-iteration.pydantic-docs.pages.dev

View logs

@github-actions
Copy link
Contributor

Coverage report

This PR does not seem to contain any modification to coverable code.

@davidhewitt
Copy link
Contributor Author

Seems like a decent win on the more targeted benchmark. The "north star" JSON validation benchmark seems to go through a wrap validator for URL validation, which seems to be a major contributor to the overall cost of validation. I'll see if I can optimize that another time.

@davidhewitt
Copy link
Contributor Author

I will also see if I can refactor to reduce the schema build regression.

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

Labels

relnotes-performance Used for performance improvements.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants