Skip to content

Conversation

@corona10
Copy link
Member

@corona10corona10 commented Jan 27, 2024

@corona10
Copy link
MemberAuthor

corona10 commented Jan 27, 2024

@colesbury

  • Py_SET_SIZE: Since Py_SET_SIZE is used for mutable collections, it is worth making it the atomic API.
  • PyList_Size: This API becomes the atomic API.
  • _Py_SET_ITEMREF is added: Too many patterns exist in the list object.c, worth adding it as the utility macro. But I'm not sure that it is located in the proper place.
  • PyList_Append, PyList_GetSlice becomes thread-safe.

@corona10corona10 changed the title gh-112087: Make PyList_{Append,GetItem,Size,GetSlice} to be thread-safegh-112087: Make PyList_{Append,Size,GetSlice} to be thread-safeJan 27, 2024
_PyList_AppendTakeRefListResize(PyListObject*self, PyObject*newitem)
{
Py_ssize_tlen=PyList_GET_SIZE(self);
Py_ssize_tlen=Py_SIZE(self);
Copy link
MemberAuthor

@corona10corona10Jan 27, 2024

Choose a reason for hiding this comment

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

It is only called by _PyList_AppendTakeRef, so it's safe.

Copy link
Contributor

@colesburycolesbury left a comment

Choose a reason for hiding this comment

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

LGTM

@corona10corona10 merged commit 7b9d406 into python:mainJan 31, 2024
@corona10corona10 deleted the gh-112087-append branch January 31, 2024 23:58
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.

2 participants

@corona10@colesbury