File tree Expand file tree Collapse file tree 1 file changed +18
-1
lines changed Expand file tree Collapse file tree 1 file changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -316,6 +316,17 @@ def _get_breaks_cached(
316316 return None
317317
318318
319+ _STR_CACHE = dict ()
320+
321+
322+ def cached_str (chunks : tuple [int , ...]) -> str :
323+ if id (chunks ) not in _STR_CACHE :
324+ value = str (chunks )
325+ _STR_CACHE [id (chunks )] = value
326+
327+ return _STR_CACHE [id (chunks )]
328+
329+
319330def _maybe_chunk (
320331 name : Hashable ,
321332 var : Variable ,
@@ -344,7 +355,13 @@ def _maybe_chunk(
344355 # by providing chunks as an input to tokenize.
345356 # subtle bugs result otherwise. see GH3350
346357 # we use str() for speed, and use the name for the final array name on the next line
347- token2 = tokenize (token if token else var ._data , str (chunks ))
358+ token2 = tokenize (
359+ token if token else var ._data ,
360+ [
361+ cached_str (_ )
362+ for _ in itertools .chain (chunks .keys (), chunks .values ())
363+ ],
364+ )
348365 name2 = f"{ name_prefix } { name } -{ token2 } "
349366
350367 from_array_kwargs = utils .consolidate_dask_from_array_kwargs (
You can’t perform that action at this time.
0 commit comments