Skip to content

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

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

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

Conversation

@kumaraditya303
Copy link
Copy Markdown
Contributor

@kumaraditya303 kumaraditya303 commented Apr 2, 2026

Copy link
Copy Markdown
Member

@ZeroIntensity ZeroIntensity left a comment

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?

Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
@kumaraditya303
Copy link
Copy Markdown
Contributor Author

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.

Copy link
Copy Markdown
Member

@vstinner vstinner left a comment

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:main Apr 7, 2026
34 checks passed
@kumaraditya303 kumaraditya303 deleted the tuple-capi branch April 7, 2026 20:25
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.

3 participants