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

Allow #[pymodule] functions to take a single module arg #3905

Merged
merged 1 commit into from
Feb 27, 2024

Conversation

maffoo
Copy link
Contributor

@maffoo maffoo commented Feb 26, 2024

After #3897. This was split off from #3899 and contains just the changes to the #[pymodule] macro.

Copy link
Contributor

@LilyFoote LilyFoote left a comment

Choose a reason for hiding this comment

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

Looks good to me!

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 is something I've wanted for a while. Obviously the first two commits are still being finalised, hopefully they can land soon and then we can get this merged.

@@ -22,6 +22,21 @@ fn basic_module(_py: pyo3::Python<'_>, m: &pyo3::types::PyModule) -> pyo3::PyRes
Ok(())
}

#[pyo3::pymodule]
fn basic_module_bound(
_py: pyo3::Python<'_>,
Copy link
Member

Choose a reason for hiding this comment

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

Was this meant to take just a single argument?

Suggested change
_py: pyo3::Python<'_>,

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch. Fixed.

@davidhewitt
Copy link
Member

Also, maybe in this PR let's update documentation to use this new one-argument form. (Or is that better for a follow up due to conflicts?)

I think this form is strictly better and closer to what we'll eventually move to in #3900

@maffoo
Copy link
Contributor Author

maffoo commented Feb 26, 2024

Also, maybe in this PR let's update documentation to use this new one-argument form. (Or is that better for a follow up due to conflicts?)

I think this form is strictly better and closer to what we'll eventually move to in #3900

I have changed the documentation to this one-arg form in #3899 which deprecates the wrap_pyfunction! macro. I can move those changes to this PR instead if you think that'd be better.

@davidhewitt
Copy link
Member

Aha fab, I confess I'd not read that PR yet. Fine to leave there 👍

@maffoo
Copy link
Contributor Author

maffoo commented Feb 27, 2024

Rebased now that #3897 is in. @davidhewitt, please take a look.

@maffoo maffoo requested a review from davidhewitt February 27, 2024 20:26
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.

Great, thanks again! 🚀

@davidhewitt davidhewitt added this pull request to the merge queue Feb 27, 2024
Merged via the queue into PyO3:main with commit a15e4b1 Feb 27, 2024
42 checks passed
@maffoo maffoo deleted the pymodule-macro branch February 28, 2024 00:41
# 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