Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
gh-112069: Make PySet_GET_SIZE to be atomic operation
  • Loading branch information
corona10 committed Apr 18, 2024
commit a4fb0bd79dcd633c08fe7787be32182954d0c502
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