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

Rename Python::with_gil -> with_python ? #3987

Open
davidhewitt opened this issue Mar 23, 2024 · 3 comments
Open

Rename Python::with_gil -> with_python ? #3987

davidhewitt opened this issue Mar 23, 2024 · 3 comments

Comments

@davidhewitt
Copy link
Member

An idea with the upcoming free threaded Python around the corner.

Maybe instead of Python::with_gil, a future PyO3 API can just be pyo3::with_python. No functional difference except dropping the GIL name as that won't always be relevant.

e.g.

Python::with_gil(|py| /* do stuff */)

becomes just

with_python(|py| /* do stuff */)

Maybe we include with_python in the prelude, maybe we invite users to import it.

@Icxolu
Copy link
Contributor

Icxolu commented Mar 30, 2024

Just throwing some alternatives in the room: Python::in_scope or Python::with_token could also be something if we want to keep it as an (associated) method, but without references to the gil.

@davidhewitt
Copy link
Member Author

davidhewitt commented Oct 11, 2024

I also have recently been thinking about Python::attach (and .allow_threads could become .detach()) - this is the terminology introduced in freethreaded Python - you're either attached to a Python thread state, or the thread state is detached from the interpreter.

@Icxolu
Copy link
Contributor

Icxolu commented Oct 14, 2024

I also have recently been thinking about Python::attach (and .allow_threads could become .detach()) - this is the terminology introduced in freethreaded Python

After reading through #4577 I think I quite like these.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants