File tree Expand file tree Collapse file tree 2 files changed +7
-0
lines changed
Expand file tree Collapse file tree 2 files changed +7
-0
lines changed Original file line number Diff line number Diff line change 1+ Avoid reading lazy arrays or on device arrays twice when comparing them to 0 during the writing process.
Original file line number Diff line number Diff line change @@ -413,6 +413,12 @@ async def _read_key(
413413 if chunk_array is None :
414414 chunk_array_batch .append (None ) # type: ignore[unreachable]
415415 else :
416+ # The operation array_equal operation below effectively will force the array
417+ # into memory.
418+ # if the result is useful, we want to avoid reading it twice
419+ # from a potentially lazy operation. So we cache it here.
420+ # If the result is not useful, we leave it for the garbage collector.
421+ chunk_array ._data = np .asarray (chunk_array ._data )
416422 if not chunk_spec .config .write_empty_chunks and chunk_array .all_equal (
417423 fill_value_or_default (chunk_spec )
418424 ):
You can’t perform that action at this time.
0 commit comments