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

Seal some traits inside impl_ submodule #4368

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

Cheukting
Copy link
Contributor

@Cheukting Cheukting commented Jul 20, 2024

Attempt to close #3908

  • First, I try sealing PyAddToModule to see if I am getting in the right direction
  • @davidhewitt Please kindly review
  • If it is correct I can try working on more of the traits

@davidhewitt davidhewitt added the CI-skip-changelog Skip checking changelog entry label Jul 21, 2024
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, this looks exactly like what we were thinking 👍

Should I merge this as-is or wait for further commits?

Comment on lines +38 to +44
impl<T> Sealed for AddTypeToModule<T> {}
impl<T> Sealed for AddClassToModule<T> {}
Copy link
Member

Choose a reason for hiding this comment

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

I had a quick reflection on whether the generic implementations here are a problem; I don't think they are as we control these types and they're hidden zero-sized types with no runtime use.

Note that something like impl<T> Sealed for Vec<T> {} would be a problem as users could then start adding other PyO3 trait implementations to Vec<MyType>, which they could then control and do stuff with.

@Cheukting
Copy link
Contributor Author

I will have a look again at this, I think we can seal more traits. Will ask for a review again when it is ready.

@Cheukting
Copy link
Contributor Author

@davidhewitt I have tried sealing most of the traits in pyclass.rs and it seems more complicated than what I did before (involving some macro as well). Do you want to have a look before I move on to other files in impl_? This seems like a big PR with lots of changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI-skip-changelog Skip checking changelog entry
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Seal traits inside impl_ submodule
2 participants