Skip to content

Commit b173f17

Browse files
committed
Remove unneeded atomics for tp_flags.
1 parent 0e995ad commit b173f17

File tree

3 files changed

+4
-10
lines changed

3 files changed

+4
-10
lines changed

Include/internal/pycore_object.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ extern int _PyDict_CheckConsistency(PyObject *mp, int check_content);
311311
// Fast inlined version of PyType_HasFeature()
312312
static inline int
313313
_PyType_HasFeature(PyTypeObject *type, unsigned long feature) {
314-
return ((FT_ATOMIC_LOAD_ULONG_RELAXED(type->tp_flags) & feature) != 0);
314+
return ((type->tp_flags) & feature) != 0;
315315
}
316316

317317
extern void _PyType_InitCache(PyInterpreterState *interp);

Include/object.h

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -776,11 +776,7 @@ PyType_HasFeature(PyTypeObject *type, unsigned long feature)
776776
// PyTypeObject is opaque in the limited C API
777777
flags = PyType_GetFlags(type);
778778
#else
779-
# ifdef Py_GIL_DISABLED
780-
flags = _Py_atomic_load_ulong_relaxed(&type->tp_flags);
781-
# else
782-
flags = type->tp_flags;
783-
# endif
779+
flags = type->tp_flags;
784780
#endif
785781
return ((flags & feature) != 0);
786782
}

Objects/typeobject.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -353,9 +353,7 @@ type_set_flags(PyTypeObject *tp, unsigned long flags)
353353
// held when flags are modified.
354354
ASSERT_TYPE_LOCK_HELD();
355355
}
356-
// Since PyType_HasFeature() reads the flags without holding the type
357-
// lock, we need an atomic store here.
358-
FT_ATOMIC_STORE_ULONG_RELAXED(tp->tp_flags, flags);
356+
tp->tp_flags = flags;
359357
}
360358

361359
static void
@@ -3690,7 +3688,7 @@ type_init(PyObject *cls, PyObject *args, PyObject *kwds)
36903688
unsigned long
36913689
PyType_GetFlags(PyTypeObject *type)
36923690
{
3693-
return FT_ATOMIC_LOAD_ULONG_RELAXED(type->tp_flags);
3691+
return type->tp_flags;
36943692
}
36953693

36963694

0 commit comments

Comments
 (0)