Skip to content

move pydantic_core -> python/pydantic_core #705

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

Merged
merged 1 commit into from
Jun 28, 2023
Merged

Conversation

davidhewitt
Copy link
Contributor

@davidhewitt davidhewitt commented Jun 27, 2023

Change Summary

This python subdirectory is recommended in the maturin README at https://github.com/PyO3/maturin#mixed-rustpython-projects

Before this PR there's some quirks where installing a pre-built pydantic_core (or with pip install .) creates oddities with pytest, because installing in this way doesn't create a .so file in the pydantic_core source directory. The .so file only gets created by pip install -e ., maturin develop, or our make build-x rules. Leads to two possible edge cases:

  • import error if you've not run anything which creates the .so in the source tree
  • uses the .so in the source tree even though you probably meant to use the "installed" .so in your environment's packages directory

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

Selected Reviewer: @samuelcolvin

@davidhewitt davidhewitt force-pushed the dh/python-source branch 3 times, most recently from ea89f99 to 385985b Compare June 27, 2023 17:00
@codspeed-hq
Copy link

codspeed-hq bot commented Jun 27, 2023

CodSpeed Performance Report

Merging #705 dh/python-source (99c446a) will improve performances by 43.55%.

Summary

🔥 41 improvements
❌ 0 regressions
✅ 84 untouched benchmarks

🆕 0 new benchmarks
⁉️ 0 dropped benchmarks

Benchmarks breakdown

Benchmark main dh/python-source Change
🔥 test_complete_core_lax 1.5 ms 1.4 ms +10.96%
🔥 test_core_python_fs 410.8 µs 348.7 µs +17.82%
🔥 test_core_python 561.7 µs 508 µs +10.57%
🔥 test_list_of_ints_core_py 3.1 ms 2.6 ms +19.54%
🔥 test_set_of_ints_core_duplicates 2.8 ms 2.4 ms +18.84%
🔥 test_frozenset_of_ints_core 1.5 ms 1.3 ms +11.42%
🔥 test_frozenset_of_ints_duplicates_core 1,184.3 µs 997.9 µs +18.69%
🔥 test_dict_of_ints_core 6.8 ms 6 ms +12.6%
🔥 test_dict_of_any_core 4.9 ms 4.2 ms +16.23%
🔥 test_many_models_core_dict 6.2 ms 5.5 ms +12.76%
🔥 test_many_models_core_model 16.3 ms 14.7 ms +10.4%
🔥 test_list_of_nullable_core 809.6 µs 641.2 µs +26.25%
🔥 test_core_future_str 31.7 µs 28.3 µs +11.94%
🔥 test_core_future 29.9 µs 26.9 µs +11.38%
🔥 test_core_future_str 26.7 µs 23.7 µs +12.55%
🔥 test_positional_tuple 32.7 µs 29.4 µs +11.41%
🔥 test_variable_tuple 32.2 µs 29.3 µs +10.05%
🔥 test_tuple_many_variable 36.5 µs 31.7 µs +15.16%
🔥 test_arguments 48.1 µs 41.6 µs +15.58%
🔥 test_generator_rust 33.3 µs 29.4 µs +13.34%
🔥 test_definition_in_tree 7.3 ms 6 ms +21.11%
🔥 test_definition_out_of_tree 11.2 ms 9.9 ms +13.34%
🔥 test_core_root_model 130.5 µs 111.6 µs +16.91%
🔥 test_tagged_union_int_keys_json 50.5 µs 45.8 µs +10.32%
🔥 test_core_dict 380 µs 286.5 µs +32.67%
🔥 test_core_dict_filter 390.4 µs 296 µs +31.9%
🔥 test_core_json 453.9 µs 396.5 µs +14.47%
🔥 test_json_direct_list_str 1,086.9 µs 928.3 µs +17.09%
🔥 test_python_json_list_str 1,006.7 µs 710.1 µs +41.76%
🔥 test_json_any_list_str 1.8 ms 1.6 ms +10.91%
🔥 test_json_direct_list_int 1,067.6 µs 905.4 µs +17.92%
🔥 test_json_any_list_int 1.7 ms 1.6 ms +11.51%
🔥 test_python_json_list_int 1,003.9 µs 706.5 µs +42.09%
🔥 test_python_json_list_none 984.7 µs 686 µs +43.55%
🔥 test_core_model_py 58.8 µs 52.2 µs +12.58%
🔥 test_core_model_py_extra 68.5 µs 60.2 µs +13.9%
🔥 test_core_model_json 53.4 µs 48.2 µs +11%
🔥 test_core_model_json_extra 63.7 µs 56.8 µs +12.13%
🔥 test_model_exclude_unset_false 62.1 µs 55.7 µs +11.53%
🔥 test_model_exclude_unset_true 76 µs 67.6 µs +12.39%
🔥 test_model_list_core_json 1,131.3 µs 969.2 µs +16.72%

@davidhewitt davidhewitt added the Full Build cause CI to do a full build label Jun 27, 2023
@adriangb
Copy link
Member

@davidhewitt how come the benchmarks are 30% faster now 🤔 ?

@davidhewitt
Copy link
Contributor Author

My hunch is that I've mistakenly enabled mimalloc, though I thought I'd fixed that...

@davidhewitt davidhewitt force-pushed the dh/python-source branch 2 times, most recently from a7617fe to 7e4ac55 Compare June 28, 2023 09:19
@codecov-commenter
Copy link

Codecov Report

Merging #705 (a4016b9) into main (29de2c9) will increase coverage by 0.00%.
The diff coverage is n/a.

❗ Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #705   +/-   ##
=======================================
  Coverage   93.73%   93.73%           
=======================================
  Files          99       99           
  Lines       13805    13807    +2     
  Branches       25       25           
=======================================
+ Hits        12940    12942    +2     
  Misses        859      859           
  Partials        6        6           
Impacted Files Coverage Δ
python/pydantic_core/__init__.py 81.81% <ø> (ø)
python/pydantic_core/core_schema.py 96.63% <ø> (ø)
src/lib.rs 100.00% <ø> (ø)

... and 1 file with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 29de2c9...a4016b9. Read the comment docs.

@davidhewitt
Copy link
Contributor Author

Ok so the answer is that with make build-prod on main we were not taking full advantage of LTO. See #707 (comment)

With this branch we are now building an optimized binary via maturin in the same way we would for production, so I argue this is now a more representative benchmark and we can eat the diff here.

@davidhewitt davidhewitt marked this pull request as ready for review June 28, 2023 10:25
@davidhewitt
Copy link
Contributor Author

please review

@davidhewitt davidhewitt merged commit f43fab3 into main Jun 28, 2023
@davidhewitt davidhewitt deleted the dh/python-source branch June 28, 2023 14:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Full Build cause CI to do a full build ready for review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants