Skip to content

Commit 83c1dc1

Browse files
committed
use isinstance instead of explicit list of codec names
1 parent b40d53a commit 83c1dc1

File tree

1 file changed

+2
-15
lines changed

1 file changed

+2
-15
lines changed

src/zarr/core/codec_pipeline.py

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -67,19 +67,6 @@ def fill_value_or_default(chunk_spec: ArraySpec) -> Any:
6767
# Thread pool for parallel codec compute
6868
# ---------------------------------------------------------------------------
6969

70-
# Codecs that are essentially free (memcpy / reshape / checksum).
71-
# Threading overhead exceeds the work these do, so we skip the pool
72-
# when these are the only codecs in the pipeline.
73-
_CHEAP_CODECS: frozenset[str] = frozenset(
74-
{
75-
"BytesCodec",
76-
"Crc32cCodec",
77-
"TransposeCodec",
78-
"VLenUTF8Codec",
79-
"VLenBytesCodec",
80-
}
81-
)
82-
8370
# Minimum chunk size (in bytes) to consider using the thread pool.
8471
# Below this, per-chunk codec work is too small to offset dispatch overhead.
8572
_MIN_CHUNK_NBYTES_FOR_POOL = 100_000 # 100 KB
@@ -104,9 +91,9 @@ def _choose_workers(n_chunks: int, chunk_nbytes: int, codecs: Iterable[Codec]) -
10491
return min_workers
10592

10693
# Only use the pool when at least one codec does real work
94+
# (BytesBytesCodec = compression/checksum, which releases the GIL in C)
10795
# and the chunks are large enough to offset dispatch overhead.
108-
has_expensive = any(type(c).__name__ not in _CHEAP_CODECS for c in codecs)
109-
if not has_expensive and min_workers == 0:
96+
if not any(isinstance(c, BytesBytesCodec) for c in codecs) and min_workers == 0:
11097
return 0
11198
if chunk_nbytes < _MIN_CHUNK_NBYTES_FOR_POOL and min_workers == 0:
11299
return 0

0 commit comments

Comments
 (0)