Skip to content

Commit

Permalink
gh-112069: Make PySet_GET_SIZE to be atomic safe. (gh-118053)
Browse files Browse the repository at this point in the history
gh-112069: Make PySet_GET_SIZE to be atomic operation
  • Loading branch information
corona10 authored Apr 18, 2024
1 parent 8f25cc9 commit 710c01b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
4 changes: 4 additions & 0 deletions Include/cpython/setobject.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ typedef struct {
(assert(PyAnySet_Check(so)), _Py_CAST(PySetObject*, so))

static inline Py_ssize_t PySet_GET_SIZE(PyObject *so) {
#ifdef Py_GIL_DISABLED
return _Py_atomic_load_ssize_relaxed(&(_PySet_CAST(so)->used));
#else
return _PySet_CAST(so)->used;
#endif
}
#define PySet_GET_SIZE(so) PySet_GET_SIZE(_PyObject_CAST(so))
1 change: 0 additions & 1 deletion Objects/setobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -2080,7 +2080,6 @@ set_issuperset_impl(PySetObject *so, PyObject *other)
Py_RETURN_TRUE;
}

// TODO: Make thread-safe in free-threaded builds
static PyObject *
set_richcompare(PySetObject *v, PyObject *w, int op)
{
Expand Down

0 comments on commit 710c01b

Please sign in to comment.