blosc2.set_nthreads#

blosc2.set_nthreads(nthreads)#

Set the number of threads to be used during Blosc operation.

Parameters:

nthreads (int) – The number of threads to be used during Blosc operation.

Returns:

out – The previous number of used threads.

Return type:

int

Raises:

ValueError – If nthreads is larger than the maximum number of threads blosc can use. If nthreads is not a positive integer.

Notes

The maximum number of threads for Blosc is \(2^{31} - 1\). In some cases Blosc gets better results if you set the number of threads to a value slightly below than your number of cores (via detect_number_of_cores()).

Examples

Set the number of threads to 2 and then to 1:

>>> oldn = blosc2.set_nthreads(2)
>>> blosc2.set_nthreads(1)
2

See also

nthreads