GeezerVison is showing github.com — gh-129069: fix more thread safety issues in list by kumaraditya303 · Pull Request #143019 · python/cpython
Conversation
kumaraditya303
commented
Dec 20, 2025
•
edited by bedevere-app
Bot
Loading
Uh oh!
There was an error while loading. Please reload this page.
This PR fixes thread safety of list.reverse and slice assignment. Also changes stores to use release rather than relaxed as done in #142957.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
I didn't measure any significant performance difference on fastbench on Apple M4.
Microbenchmarks for list.insert are a little slower on that same machine. Here's the benchmark (courtesy of ChatGPT):
https://gist.github.com/colesbury/b675c95d35f29ca9d5723b95396d48a8
Before:
begin n=100000 reps=1000 total=0.032732s avg=32.73µs/op
middle n=100000 reps=1000 total=0.013755s avg=13.76µs/op
end n=100000 reps=1000 total=0.000564s avg=0.56µs/op
After:
begin n=100000 reps=1000 total=0.048336s avg=48.34µs/op
middle n=100000 reps=1000 total=0.019781s avg=19.78µs/op
end n=100000 reps=1000 total=0.000191s avg=0.19µs/op
We could use ptr_wise_atomic_memmove in many of these places, which will probably be faster in the microbenchmarks, but I'm not sure it'll matter in real programs.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Reviewers
Yhg1s
Awaiting requested review from Yhg1s
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.