Skip to content

RFC: Drop EnsureGIL to remove one layer of indirection from the implementation of Python::with_gil#3166

Merged
bors[bot] merged 1 commit intomainfrom
drop-ensure-gil
May 23, 2023
Merged

RFC: Drop EnsureGIL to remove one layer of indirection from the implementation of Python::with_gil#3166
bors[bot] merged 1 commit intomainfrom
drop-ensure-gil

Conversation

@adamreichold
Copy link
Member

I am not sure if other people would consider this a simplification as well, but it helped me to remove one layer of indirection used by the implementation of Python::with_gil, especially flattening the Option<_> layers in EnsureGIL and GILGuard::pool. This makes it obvious that we always create GILPool when we actually acquire the GIL. (Of course, there still might be extra GILPool instances created manually.)

@adamreichold adamreichold added the CI-skip-changelog Skip checking changelog entry label May 20, 2023
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.

Cool. Looks good to me. At least, I don't see any benefit of having Option<GILPool> in the struct.

@adamreichold adamreichold force-pushed the drop-ensure-gil branch 2 times, most recently from b8ef9a3 to 3b3eead Compare May 22, 2023 07:25
@adamreichold
Copy link
Member Author

@davidhewitt Since this is strictly refactoring only, I think this would be good to merge based on one review. But then again this code is somewhat involved/unsafe and you wrote most of the module in question. Would you like to give this a review yourself or do you think we can merge this without it?

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.

Yep, I think this is good to merge. Nice tidy up! 👍

@adamreichold
Copy link
Member Author

bors r=davidhewitt

bors bot added a commit that referenced this pull request May 23, 2023
3166: RFC: Drop EnsureGIL to remove one layer of indirection from the implementation of Python::with_gil r=davidhewitt a=adamreichold

I am not sure if other people would consider this a simplification as well, but it helped me to remove one layer of indirection used by the implementation of `Python::with_gil`, especially flattening the `Option<_>` layers in `EnsureGIL` and `GILGuard::pool`. This makes it obvious that we always create `GILPool` when we actually acquire the GIL. (Of course, there still might be extra `GILPool` instances created manually.)

Co-authored-by: Adam Reichold <adam.reichold@t-online.de>
@adamreichold
Copy link
Member Author

bors retry

@bors
Copy link
Contributor

bors bot commented May 23, 2023

Canceled.

@bors
Copy link
Contributor

bors bot commented May 23, 2023

Build succeeded!

The publicly hosted instance of bors-ng is deprecated and will go away soon.

If you want to self-host your own instance, instructions are here.
For more help, visit the forum.

If you want to switch to GitHub's built-in merge queue, visit their help page.

@bors bors bot merged commit 3a773c7 into main May 23, 2023
@bors bors bot deleted the drop-ensure-gil branch May 23, 2023 22:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CI-skip-changelog Skip checking changelog entry

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants