Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

pycfunction: take &'static str arguments to new #1450

Merged
merged 1 commit into from
Feb 27, 2021

Conversation

davidhewitt
Copy link
Member

This is a follow-up to #1446 to refactor PyCFunction a little bit to re-use code and get rid of one transmute call at the same time.

I had to change the name and doc arguments to PyCFunction::new() to take &'static str instead of just &str. This is a good change in my opinion because the underlying Python APIs need 'static data anyway. Previously we always had to copy the string and leak the copy; now we can forward the pointer to the underlying string (as long as it's a valid c-string).

Copy link
Member

@kngwyu kngwyu left a comment

Choose a reason for hiding this comment

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

Thanks, I think it's almost OK.

Co-authored-by: messense <messense@icloud.com>
@davidhewitt
Copy link
Member Author

Changes pushed - thanks both for the reviews!

@davidhewitt davidhewitt merged commit 40777a6 into PyO3:master Feb 27, 2021
@davidhewitt davidhewitt deleted the pycfunction-static branch February 27, 2021 17:07
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants