Threading

APyTypes supports multi-threading for certain operations, allowing for improved performance in some cases.

apytypes.n_threads() int

Return the number of threads active in the APyTypes thread pool.

On startup, a suitable number of threads is automatically determined by APyTypes, unless the environment variable APYTYPES_THREAD_COUNT is set. In that case, the thread pool is initialized with int(APYTYPES_THREAD_COUNT) number of threads.

Added in version 0.5.

Returns:
int

Number of threads in the APyTypes thread pool.

apytypes.reset_thread_pool(n_threads: int) None

Reset the APyTypes thread pool with a new thread count.

If n_threads == 0, the thread pool will determine a suitable number of threads on its own.

Added in version 0.5.

Parameters:
n_threadsint

Number of threads in the new thread pool. Zero to let APyTypes decide.