From 7e8e717423c5be35636fb4cadc394955c4c74180 Mon Sep 17 00:00:00 2001 From: Deepak Cherian Date: Sat, 20 Jan 2024 15:23:35 -0700 Subject: [PATCH] Add threshold --- flox/core.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/flox/core.py b/flox/core.py index c7455a05a..cdb2b4ab8 100644 --- a/flox/core.py +++ b/flox/core.py @@ -260,7 +260,8 @@ def chunk_unique(labels, slicer, nlabels, label_is_present=None): uniques = ilabels[label_is_present[:-1]] return uniques - if nlabels < approx_chunk_size: + if nlabels < 5 * approx_chunk_size: + logger.debug("Using threadpool since %s < 5 * %s", nlabels, approx_chunk_size) with ThreadPoolExecutor() as executor: futures = [ executor.submit(chunk_unique, labels, slicer, nlabels)