@@ -293,40 +293,26 @@ attribute tends to be faster than a plain global variable in compiled code::
293293Free threading
294294--------------
295295
296- Mypyc supports free threading, but it doesn't provide the exact
297- memory safety guarantees as Python in compiled modules under
298- free threading when there are race conditions.
299-
300- Additionally, optimized primitive operations in compiled code may have
301- different atomicity properties compared to CPython. Use explicit
302- synchronization if code depends on operations being atomic. This is
303- already the recommended approach for normal Python code.
304-
305- Currently, compiled code must ensure that proper synchronization is
306- used to prevent data races involving non-final attributes in native
307- classes, unless the attribute has a value type such as ``bool ``,
308- ``float `` or ``i64 ``. You can use explicit
309- synchronization, such as via
310- :ref: `librt.threading.Lock <librt-threading-lock >` (or
311- :py:class: `threading.Lock `, which is less efficient than
312- ``librt.threading.Lock ``) if there is a possibility of such a data
313- race.
296+ Mypyc supports free threading. However, optimized primitive operations in
297+ compiled code may have different atomicity properties compared to CPython.
298+ Use explicit synchronization if code depends on operations being atomic and
299+ race conditions are possible. This is already the recommended approach for
300+ normal Python code. You can often use :ref: `librt.threading.Lock <librt-threading-lock >`
301+ (or :py:class: `threading.Lock `, which is less efficient than
302+ ``librt.threading.Lock ``) to fix data races.
303+
304+ Since mypyc 2.3, the vast majority of operations are memory safe even if
305+ there are race conditions (unlike earlier mypyc releases). This includes
306+ list operations and access to native instance attributes (except for
307+ a few less common use cases that will be fixed in future releases).
314308
315309.. note ::
316310
317- We are working on improving memory safety in free-threading
318- builds of Python, and hope to make all normal Python features
319- memory safe, while providing more efficient but less safe
320- opt-in, non-standard features.
321-
322- As libraries often won't be able to control the concurrent access by
323- user code, we recommend that modules document that multi-threaded
324- access is only supported via public interfaces that ensure correct
325- synchronization. Marking attributes as internal using an underscore
326- attribute prefix is another possibility, but this is not enforced at
327- runtime. Another option is to document that multithreaded access is
328- not supported, or that particular objects should not be used from
329- multiple threads concurrently.
311+ Operations that aren't safe under race conditions in interpreted CPython
312+ are not expected to be memory safe in compiled code either.
313+ Some :ref: `librt <librt >` features are heavily optimized for performance and
314+ don't guarantee memory safety when there are race conditions
315+ (notably the :ref: `vec <librt-vecs >` type).
330316
331317It's always safe to perform read-only operations concurrently. Using
332318objects with final attributes and tuple objects can help prevent
0 commit comments