Skip to content

gh-142518: add thread safety annotations for tuple C-API - #148012

Merged
kumaraditya303 merged 6 commits into
python:mainfrom
kumaraditya303:tuple-capi
Apr 7, 2026
Merged

gh-142518: add thread safety annotations for tuple C-API#148012
kumaraditya303 merged 6 commits into
python:mainfrom
kumaraditya303:tuple-capi

Conversation

@kumaraditya303

@kumaraditya303kumaraditya303 commented Apr 2, 2026

Copy link
Copy Markdown
Contributor

@ZeroIntensityZeroIntensity left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't PyTuple_SetItem thread-safe on an "existing" tuple if the tuple is uniquely referenced?

Comment threadDoc/c-api/tuple.rst Outdated
Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
@kumaraditya303

Copy link
Copy Markdown
ContributorAuthor

Isn't PyTuple_SetItem thread-safe on an "existing" tuple if the tuple is uniquely referenced?

Yes, that's what the docs mean by "This function should only be used to fill in brand new tuples" as brand new tuples are uniquely referenced.

@vstinnervstinner left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@kumaraditya303
kumaraditya303 merged commit 03d712e into python:mainApr 7, 2026
34 checks passed
@kumaraditya303
kumaraditya303 deleted the tuple-capi branch April 7, 2026 20:25
ljfp pushed a commit to ljfp/cpython that referenced this pull request Apr 25, 2026
Sign up for freeto 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.

3 participants

@kumaraditya303@vstinner@ZeroIntensity