@@ -66,10 +66,44 @@ PyList_Reverse:shared:
6666# is a list
6767PyList_SetSlice:shared:
6868
69- # Sort - per-object lock held; comparison callbacks may execute
70- # arbitrary Python code
69+ # Sort - per-object lock held; the list is emptied before sorting
70+ # so other threads may observe an empty list, but they won't see the
71+ # intermediate states of the sort
7172PyList_Sort:shared:
7273
7374# Extend - lock target list; also lock source when it is a
7475# list, set, or dict
7576PyList_Extend:shared:
77+
78+ # Creation - pure allocation, no shared state
79+ PyBytes_FromString:atomic:
80+ PyBytes_FromStringAndSize:atomic:
81+ PyBytes_DecodeEscape:atomic:
82+
83+ # Creation from formatting C primitives - pure allocation, no shared state
84+ PyBytes_FromFormat:atomic:
85+ PyBytes_FromFormatV:atomic:
86+
87+ # Creation from object - uses buffer protocol so may call arbitrary code;
88+ # safe as long as the buffer is not mutated by another thread during the operation
89+ PyBytes_FromObject:shared:
90+
91+ # Size - uses atomic load on free-threaded builds
92+ PyBytes_Size:atomic:
93+ PyBytes_GET_SIZE:atomic:
94+
95+ # Raw data - no locking; mutating it is unsafe if the bytes object is shared between threads
96+ PyBytes_AsString:compatible:
97+ PyBytes_AS_STRING:compatible:
98+ PyBytes_AsStringAndSize:compatible:
99+
100+ # Concatenation - uses buffer protocol; safe as long as buffer is not mutated by another thread during the operation
101+ PyBytes_Concat:shared:
102+ PyBytes_ConcatAndDel:shared:
103+ PyBytes_Join:shared:
104+
105+ # Resizing - safe if the object is unique
106+ _PyBytes_Resize:distinct:
107+
108+ # Repr - atomic as bytes are immutable
109+ PyBytes_Repr:atomic:
0 commit comments