Thread Safety Guarantees — Python 3.16.0a0 documentation

docs.python.org

Tin mới

Built-in Exceptions

Time complexity of operations on built-in types

Python Module Index

3.16.0a0 Documentation

The Python Standard Library

Thread safety levels¶

This page documents thread-safety guarantees for built-in types in Python’s free-threaded build. The guarantees described here apply when using Python with the GIL disabled (free-threaded mode). When the GIL is enabled,

Python support for free threading

This page documents thread-safety guarantees for built-in types in Python’s free-threaded build. The guarantees described here apply when using Python with the GIL disabled (free-threaded mode). When the GIL is enabled,

Safe on shared objects¶

A function or operation that is safe for concurrent use on the same object. The implementation uses internal synchronization (such as per-object locks or critical sections) to protect shared mutable state, so callers do

PyList_GetItemRef()

A function or operation that is safe for concurrent use on the same object. The implementation uses internal synchronization (such as per-object locks or critical sections) to protect shared mutable state, so callers do

Thread safety for list objects¶

The following methods traverse the list and use atomic reads of each item to perform their function. That means that they may return results affected by concurrent modifications:

Thread safety for list objects¶

The following methods traverse the list and use atomic reads of each item to perform their function. That means that they may return results affected by concurrent modifications:

Thread safety for dict objects¶

Creating a dictionary with the dict constructor is atomic when the argument to it is a dict or a tuple. When using the dict.fromkeys() method, dictionary creation is atomic when the argument is a dict, tuple, set or froz