blosc2.set_releasegil¶
- blosc2.set_releasegil(gilstate: bool) bool[source]¶
Set whether to release the Python global inter-lock (GIL) during c-blosc compress and decompress operations or not. This defaults to False.
- Parameters:
gilstate¶ (bool) – True to release the GIL, False to retain it.
- Returns:
out – The previous value of the Python global inter-lock (GIL) release state.
- Return type:
Notes
Designed to be used with larger chunk sizes and a ThreadPool. There is a small performance penalty with releasing the GIL that will more harshly penalize small block sizes.
Reading slices of an NDArray releases the GIL while decompressing regardless of this setting, unless a Python postfilter, codec or filter could run during the read.
Compressing keeps the GIL regardless of this setting when a Python callback (a prefilter, a filler, or a codec or filter registered from Python) could run.
decompress2()keeps it when the chunk uses a codec or filter registered from Python.Examples
>>> oldReleaseState = blosc2.set_releasegil(True) >>> _ = blosc2.set_releasegil(oldReleaseState)