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

feat: add type alias InternString for macro intern! #4366

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Stargateur
Copy link

No description provided.

@Stargateur Stargateur force-pushed the add-intern-string branch 4 times, most recently from a54e5f3 to 5a517dd Compare July 20, 2024 06:33
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, I can kind of see why this is helpful though I also wonder why this is happening enough that this seems worth having in PyO3 itself rather than user code? It's relatively trivial for this one-liner to be written downstream by those who want it.

src/lib.rs Outdated Show resolved Hide resolved
@Stargateur
Copy link
Author

Thanks, I can kind of see why this is helpful though I also wonder why this is happening enough that this seems worth having in PyO3 itself rather than user code? It's relatively trivial for this one-liner to be written downstream by those who want it.

Well, trivial or not that one line every user will maybe add when pyo3 can do it. that the main purpose of lib, share common code. I see no con to this cause change the return type of intern! would be breaking change anyway. This also add clarity cause the return type of the macro was undocumented.

I need this cause the macro would create a string if I call it from multiple location, so I used function that return the string:

/// Return the interned string "foo".
fn foo(py: Python) -> InternString {
    intern!(py, "foo")
}

was more clear than:

/// Return the interned string "foo".
fn foo(py: Python) -> &pyo3::Bound<PyString> {
    intern!(py, "foo")
}

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.

2 participants