Skip to content

Conversation

@kumaraditya303
Copy link
Contributor

@kumaraditya303 kumaraditya303 commented Dec 20, 2025

This PR fixes thread safety of list.reverse and slice assignment. Also changes stores to use release rather than relaxed as done in #142957.

Copy link
Contributor

@colesbury colesbury left a 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.

@kumaraditya303 kumaraditya303 merged commit 487e91c into python:main Dec 22, 2025
48 checks passed
@kumaraditya303 kumaraditya303 deleted the atomic-list branch December 22, 2025 16:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants