Skip to content

Conversation

@davidhewitt
Copy link
Contributor

@davidhewitt davidhewitt commented Jun 24, 2024

Change Summary

Updates to PyO3 0.22

Related issue number

Closes #1175
Closes #1292

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

@codspeed-hq
Copy link

codspeed-hq bot commented Jun 24, 2024

CodSpeed Performance Report

Merging #1340 will not alter performance

Comparing dh/pyo3-0.22 (77387e4) with dh/pyo3-0.22 (ae0bdd0)

Summary

✅ 155 untouched benchmarks

Comment on lines -477 to -481
let fields = schema
.get_as_req::<&PyList>(intern!(py, "fields"))?
.iter()
.map(|s| Ok(s.downcast::<PyString>()?.into_py(py)))
.collect::<PyResult<Vec<_>>>()?;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why don't we need this anymore?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Type inference is able to work out that we want fields to be Vec<Py<PyString>>, so best to let PyO3 decide the most efficient way to achieve that.

This code was flagged to me because &PyList is now removed as a type (we always wrap it as Py<PyList> or Bound<'_, PyList> now), so I simplified :)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great!

Copy link
Contributor

@sydney-runkle sydney-runkle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, thanks for helping me to understand some of these changes.

I think we'll also want to add support for 3.13 to CI?

@davidhewitt davidhewitt added the Full Build cause CI to do a full build label Jun 24, 2024
Copy link
Contributor

@sydney-runkle sydney-runkle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, pending CI :).

@sydney-runkle
Copy link
Contributor

Ah also we can update pyproject.toml to reflect 3.13 support

@davidhewitt davidhewitt changed the title update to PyO3 0.22 update to PyO3 0.22, add 3.13 support Jun 24, 2024
@davidhewitt davidhewitt marked this pull request as ready for review June 24, 2024 22:21
@davidhewitt davidhewitt enabled auto-merge (squash) June 24, 2024 22:22
@davidhewitt davidhewitt merged commit ef7f81c into main Jun 24, 2024
@davidhewitt davidhewitt deleted the dh/pyo3-0.22 branch June 24, 2024 22:31
# arm pypy and older pythons which can't be run on the arm hardware for PGO
#
# FIXME https://github.com/PyO3/maturin-action/issues/275
# cffi prevents `maturin-action` working on macOS 3.13 for now for the optimized build
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cffi is close, they have a pre release out with support :)

davidhewitt added a commit to pydantic/pydantic that referenced this pull request Oct 22, 2025
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

generate_self_schema.py incompatible with Python 3.13.0b1 [Heads up] test_invalid_regex fails with Python 3.13.0a3 (re.Error renamed to PatternError)

3 participants