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

macros: simpler expansion for intern! #2413

Merged
merged 1 commit into from
Jun 2, 2022

Conversation

davidhewitt
Copy link
Member

Adds a helper Interned struct to contain the implementation of the intern! macro. Simplifies the expanded code a little, should allow the compiler to re-use the one monomorphization of get_or_init.

@davidhewitt davidhewitt requested a review from adamreichold June 1, 2022 08:10
Copy link
Member

@adamreichold adamreichold left a comment

Choose a reason for hiding this comment

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

Nice! Seems like a vastly cleaner implementation.

@mejrs
Copy link
Member

mejrs commented Jun 1, 2022

Does this implementation continue to forbid patterns like #2269 (comment)? I think that the const-ness of new takes care of that problem, but i'm not 100% sure.

@davidhewitt
Copy link
Member Author

Does this implementation continue to forbid patterns like #2269 (comment)? I think that the const-ness of new takes care of that problem, but i'm not 100% sure.

I think so too, though I'll add a test to be sure.

@davidhewitt davidhewitt merged commit f50406a into PyO3:main Jun 2, 2022
@davidhewitt davidhewitt deleted the simpler-interned branch June 2, 2022 11:54
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