phasorpy.utils#
Utility functions.
The phasorpy.utils
module provides auxiliary and convenience functions
that do not naturally fit into other modules.
- phasorpy.utils.number_threads(num_threads=None, max_threads=None, /)[source]#
Return number of threads for parallel computations on CPU cores.
This function is used to parse
num_threads
parameters.- Parameters:
num_threads (int, optional) – Number of threads to use for parallel computations on CPU cores. If None (default), return 1, disabling multi-threading. If greater than zero, return value up to max_threads if set. If zero, return the value of the
PHASORPY_NUM_THREADS
environment variable if set, else half the CPU cores up to max_threads or 32.max_threads (int, optional) – Maximum number of threads to return.
Examples
>>> number_threads() 1 >>> number_threads(0) 8