GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-129069: fix more thread safety issues in list by kumaraditya303 · Pull Request #143019 · python/cpython

Conversation

@kumaraditya303

@kumaraditya303 kumaraditya303 commented Dec 20, 2025 •
edited by bedevere-app Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

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

  • Issue: Race in concurrent list mutation and item retrieval #129069

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@bedevere-app bedevere-app Bot mentioned this pull request Dec 20, 2025
Race in concurrent list mutation and item retrieval #129069
Closed
@bedevere-app bedevere-app Bot added the awaiting core review label Dec 20, 2025
@kumaraditya303 kumaraditya303 added skip news topic-free-threading labels Dec 20, 2025
@kumaraditya303
fix more thread safety issues in list
908a590
@kumaraditya303
kumaraditya303 force-pushed the atomic-list branch from 8830614 to 908a590 Compare December 20, 2025 12:30
@kumaraditya303
kumaraditya303 requested review from Yhg1s and colesbury December 20, 2025 13:39
colesbury
colesbury approved these changes Dec 22, 2025
View reviewed changes

@colesbury colesbury left a comment

Copy link
Copy Markdown
Contributor

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.

All reactions
@bedevere-app bedevere-app Bot added awaiting merge and removed awaiting core review labels Dec 22, 2025
@kumaraditya303
kumaraditya303 merged commit 487e91c into python:main Dec 22, 2025
48 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app bedevere-app Bot removed the awaiting merge label Dec 22, 2025
@kumaraditya303
kumaraditya303 deleted the atomic-list branch December 22, 2025 16:15
@nascheme nascheme mentioned this pull request Jul 14, 2026
Backport free-threading memory-safety fixes to 3.14 and 3.15 #153714
Closed
@bedevere-app

bedevere-app Bot commented Jul 16, 2026

Copy link
Copy Markdown

GH-153791 is a backport of this pull request to the 3.14 branch.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@kumaraditya303 kumaraditya303 mentioned this pull request Jul 16, 2026
[3.14] gh-123471: Free-threading fixes for itertools (GH-131212) (GH-132814) (GH-135689) (GH-144402) (GH-146033) (GH-142957) #153791
Merged
@KRRT7 KRRT7 mentioned this pull request Sep 30, 2026
[3.14] gh-129069: fix more thread safety issues in list (GH-143019) #158488
Closed
@bedevere-app

bedevere-app Bot commented Sep 30, 2026

Copy link
Copy Markdown

GH-158488 is a backport of this pull request to the 3.14 branch.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

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

Reviewers

@colesbury colesbury colesbury approved these changes
@Yhg1s Yhg1s Awaiting requested review from Yhg1s

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

skip news topic-free-threading

Projects

None yet

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.

2 participants

@kumaraditya303 @colesbury
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.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.