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

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

merged 1 commit into from Feb 27, 2021


Copy link

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).

src/class/ Outdated Show resolved Hide resolved
src/class/ Outdated Show resolved Hide resolved
Copy link

@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.

src/class/ Outdated Show resolved Hide resolved
Co-authored-by: messense <>
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
None yet

Successfully merging this pull request may close these issues.

None yet

3 participants