Skip to content

[mypyc] Make list.pop() atomic on free-threaded builds - #22215

Merged
JukkaL merged 1 commit into
masterfrom
mypyc-bulkfix-1196-ft-list-pop
Oct 16, 2026
Merged

JukkaL merged 1 commit into
masterfrom
mypyc-bulkfix-1196-ft-list-pop

Conversation

@JukkaL

@JukkaL JukkaL commented Oct 16, 2026

Copy link
Copy Markdown
Collaborator

Fix mypyc/mypyc#1196.

Remove the item directly while holding the list's critical section, using the same steps as del a[i] in CPython, instead of getting and deleting the item in separate operations. This avoids an extra incref/decref pair and a nested critical section, so pop() is also faster than the previous non-atomic implementation (15-37% in microbenchmarks).

Fix mypyc/mypyc#1196.

Remove the item directly while holding the list's critical section, using
the same steps as `del a[i]` in CPython, instead of getting and deleting
the item in separate operations. This avoids an extra incref/decref pair
and a nested critical section, so pop() is also faster than the previous
non-atomic implementation (15-37% in microbenchmarks).
@JukkaL
JukkaL merged commit 8841ff1 into master Oct 16, 2026
18 checks passed
@JukkaL
JukkaL deleted the mypyc-bulkfix-1196-ft-list-pop branch October 16, 2026 14:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Free-threaded CPython 3.14: container locking gaps and mypyc typed-list operation path mismatch

2 participants