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

PyO3: complete Bound migration and disable gil-refs feature on pyo3 crate #21499

Merged

Conversation

tdyas
Copy link
Contributor

@tdyas tdyas commented Oct 5, 2024

Complete the migration to the pyo3::Bound smart pointer and disable the gil-refs feature on the pyo3 crate so any use of the "GIL refs" API will be flagged as a deprecation (which our source will error for).

@tdyas tdyas added category:internal CI, fixes for not-yet-released features, etc. release-notes:not-required PR doesn't require mention in release notes labels Oct 5, 2024
@@ -153,12 +156,19 @@ impl AddressInput {
_cls: &Bound<'_, PyType>,
spec: &str,
description_of_origin: &str,
relative_to: Option<&str>,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

These changes from &str to String are necessiated by the &str lifetime when extracted no longer lasting as long as the 'py GIL lifetime. See the discussion in the PyO3 migration guide for how to deal with this change.

The guide advises to use the new PyBackedStr instead of &str but in this method the &str lifetime was complex enough to warrant just extracting an owned String.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm assuming we don't expect the allocation overhead to be user-noticeable?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I didn't get far enough to consider that since I plan to find a way to use references again. The code was encountering "fun" error messages as I tried to sort out the lifetimes for the references. Easier to do this and get the upgrade done first and then come back to this function with PyO3 v0.22 in place and have a focused PR to do it the right way.

@tdyas
Copy link
Contributor Author

tdyas commented Oct 5, 2024

This PR stacks on top of #21498 which should be reviewed first.

@tdyas tdyas requested review from benjyw and huonw October 7, 2024 20:29
@tdyas tdyas marked this pull request as ready for review October 7, 2024 20:29
@tdyas tdyas mentioned this pull request Oct 7, 2024
@@ -153,12 +156,19 @@ impl AddressInput {
_cls: &Bound<'_, PyType>,
spec: &str,
description_of_origin: &str,
relative_to: Option<&str>,
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm assuming we don't expect the allocation overhead to be user-noticeable?

@tdyas tdyas merged commit b3d249f into pantsbuild:main Oct 8, 2024
25 checks passed
@tdyas tdyas deleted the pyo3/switch-to-bound/disable-gil-refs-feature branch October 8, 2024 02:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category:internal CI, fixes for not-yet-released features, etc. release-notes:not-required PR doesn't require mention in release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants