The ft_utils API is organized into several modules, each providing a specific set of functionalities.
The concurrent module provides a set of foundational structures to implement scalable and efficient Free Threaded code. Using these structures can help avoid bottlenecks and enhance thread-consistency in FTPython code.
The synchronization module provides specialized lock types that work in GIL-based Python and offer significant benefits for Free Threaded programming. These locks can help improve the performance and reliability of concurrent code.
The local module provides helper classes to move certain forms of processing from being cross-thread to being local to a thread. These classes are necessary to avoid key bottlenecks that can occur due to cache contention, critical sections, and reference counting in Free Threaded Python.
The ft_compat header provides backward compatibility for native code.
For developers writing native code (C, C++, Rust, etc.) that interacts with the Python C API, ft_compat.h
provides a backwards compatibility layer for Free Threading-related APIs. This allows you to write code that takes advantage of Free Threading features, such as atomic operations and critical sections, while still maintaining support for older versions of Python. By using ft_compat.h
, you can ensure that your native code is compatible with multiple versions of Python, reducing maintenance and testing efforts.