Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor Input trait to have single as_python cast for python inputs #1241

Merged
merged 1 commit into from
Mar 21, 2024

Conversation

davidhewitt
Copy link
Contributor

Change Summary

Looking at performance of new pydantic-core in pydantic's north star benchmark, I noticed that an easy perf win is to avoid copying Url and MultiHostUrl objects when unnecessary.

At the same time, I refactored the Input trait just a little bit so that all the python-specific methods could be replaced by a single .as_python() call which validators with targeted optimizations could then use.

Related issue number

N/A

Checklist

  • Unit tests for the changes exist
  • Documentation reflects the changes where applicable
  • Pydantic tests pass with this pydantic-core (except for expected changes)
  • My PR is ready to review, please add a comment including the phrase "please review" to assign reviewers

Copy link

codspeed-hq bot commented Mar 21, 2024

CodSpeed Performance Report

Merging #1241 will not alter performance

Comparing dh/url-optimization (64c648b) with main (6399592)

Summary

✅ 152 untouched benchmarks

@davidhewitt
Copy link
Contributor Author

It looks like we are missing Url benchmarks, but hopefully this is clear enough....

@davidhewitt davidhewitt changed the title avoid copying Url objects when possible refactor Input trait to have single as_python cast for python inputs Mar 21, 2024
@davidhewitt davidhewitt merged commit ebf55d6 into main Mar 21, 2024
27 of 28 checks passed
@davidhewitt davidhewitt deleted the dh/url-optimization branch March 21, 2024 10:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant