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

Use addr_of_mut in pyo3-ffi #2172

Merged
merged 3 commits into from
Feb 19, 2022
Merged

Use addr_of_mut in pyo3-ffi #2172

merged 3 commits into from
Feb 19, 2022

Conversation

mejrs
Copy link
Member

@mejrs mejrs commented Feb 16, 2022

All these comparisons and getters were going through &mut references to mutable statics...

Ok(())
}

fn rustc_minor_version() -> Option<u32> {
Copy link
Member

Choose a reason for hiding this comment

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

PyO3 itself already uses the rustversion, wouldn't it make sense to apply it here as well?

Copy link
Member Author

Choose a reason for hiding this comment

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

The rustversion crate? That is only a dev dependency.

Copy link
Member

@adamreichold adamreichold Feb 16, 2022

Choose a reason for hiding this comment

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

Indeed, wouldn't also just be build-dependency if used in the build script here?

I understand that it is meant to be used directly for conditional compilation, but that could also be applied to the println! invocation in the build script to avoid manually parsing the version.

Or at least could we somehow deduplicate the parsing code between the build scripts of pyo3 and pyo3-ffi?

Copy link
Member Author

Choose a reason for hiding this comment

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

Last time I discussed it @davidhewitt (I think?) didn't want to add dependencies, so I didn't do it here. I would prefer not to reinvent the wheel but I also don't want to add more macro crates as dependencies.

Copy link
Member Author

Choose a reason for hiding this comment

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

I feel kind of split between deduplicating the code - I don't like duplication either but it's not a whole lot and it doesn't do anything clever, so i don't think the cost of duplication is great here. And we'll just delete it all next time we bump msrv.

Copy link
Member

Choose a reason for hiding this comment

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

Yes, I keep going back and forth whether we should add rustversion and refactor our build scripts. On the one hand, it might be nice to use the dependency to keep our code a bit simpler. On the other, it keeps our dependency tree leaner to just do it ourselves. I slightly prefer the current implementation, though only slightly so if you folks wanted to change to rustversion that's fine by me.

Copy link
Member

Choose a reason for hiding this comment

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

To avoid the duplication could always shove it into pyo3-build-config as a #[doc(hidden)] API :P

Copy link
Member Author

Choose a reason for hiding this comment

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

The current implementation is pretty simple. I'll just keep that.

To avoid the duplication could always shove it into pyo3-build-config as a #[doc(hidden)] API :P

Yeah, I'll do just that.

Copy link
Member

@davidhewitt davidhewitt left a comment

Choose a reason for hiding this comment

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

Thanks, a nice tidy up!

Happy for you folks to decide on rustversionand addr_of_mut / addr_of_mut_shim and merge at your leisure.

@davidhewitt davidhewitt mentioned this pull request Feb 17, 2022
@mejrs mejrs requested a review from adamreichold February 18, 2022 19:41
@mejrs mejrs merged commit 01788b7 into PyO3:main Feb 19, 2022
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.

3 participants