GeezerVison is showing github.com — gh-117953: Refactor Import Machinery Code for Extension Modules by ericsnowcurrently · Pull Request #118116 · python/cpython
Conversation
This is a large change that involves refactoring the code that loads extension modules. The objective is partly to improve the clarity of the code, but mostly it's so that I can execute a subset of the constituent operations in a subsequent PR.
The changes include:
While this aligns with the sort of thing I've wanted to do for a long time, the main motivation at the moment is to drastically reduce the likelihood of problems from loading a single-phase init extension module in an isolated subinterpreter. Nearly all the changes here come from what I found I needed for a (relatively) simple solution to the isolation problem. Consequently, much of the refactoring follows the natural divisions in the flow of operations when loading an extension module.
For the sake of reducing the burden of code review for such a large change, I have purposefully avoided changing any behavior in this PR, regardless of how benign it might seem. That said, if it's still too much I'm okay with splitting this up.
For context, this is the first of 3 branches in a chain. Here are the other two, in order:
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
@encukou, content aside, do you think this change is too big, considering that it's mostly moving things around and adding a few data structures to help with that? I'd be glad to split this up if that would help, but would rather not. 😄
Don't spend much time on an answer. I'm not sure what my own answer would be yet, other than I think it's fine in priniciple. I just wanted to see if you had a quick opinion, given your experience with the code I'm changing.
FWIW, I'm going to let this sit over the weekend and give myself a review on Monday.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
encukou
commented
Apr 22, 2024
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
Don't spend much time on an answer.
It's giant! :)
Do you see some parts that would be an improvement on their own, which could be split out and reviewed separately? Perhaps some mechanical stuff like replacing MODULES with get_modules_dict would make the big patch more focused (though if it's only that, it won't help much).
If you don't, this patch is certainly reviewable -- over a few days. I sent a similar giant patch recently, where I couldn't figure out how to break it down further.
|
ericsnowcurrently reacted with thumbs up emoji
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This was referenced Apr 22, 2024
|
Sounds good. I'm splitting this up into 6 different PRs. They should all be up by tomorrow.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
ericsnowcurrently
added a commit
that referenced
this pull request
Apr 23, 2024
)
This is a collection of very basic cleanups I've pulled out of gh-118116. It is mostly renaming variables and moving a couple bits of code in functionally equivalent ways.
This was referenced Apr 23, 2024
This was referenced Apr 24, 2024
ericsnowcurrently
added a commit
that referenced
this pull request
Apr 24, 2024
These are cleanups I've pulled out of gh-118116. Mostly, this change moves code around to align with some future changes and to improve clarity a little. There is one very small change in behavior: we now add the module to the per-interpreter caches after updating the global state, rather than before.
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
|