@@ -553,6 +553,7 @@ def slices_eval(
553553 # Iterate over the operands and get the chunks
554554 chunks_idx , nchunks = get_chunks_idx (shape , chunks )
555555 lenout = 0
556+ behaved = False
556557 for nchunk in range (nchunks ):
557558 coords = tuple (np .unravel_index (nchunk , chunks_idx ))
558559 chunk_operands = {}
@@ -634,18 +635,22 @@ def slices_eval(
634635 out = blosc2 .empty (shape_ , dtype = result .dtype , ** kwargs )
635636 else :
636637 out = blosc2 .empty (shape_ , dtype = result .dtype , ** kwargs )
638+ # Check if the in out partitions are well-behaved (i.e. no padding)
639+ behaved = are_partitions_behaved (out .shape , out .chunks , out .blocks )
640+ print (f"Behaved: { behaved } " )
637641
638- if where is None :
639- out [slice_ ] = result
640- else :
641- if len (where ) == 2 :
642- out [slice_ ] = result
643- elif len (where ) == 1 :
644- lenres = len (result )
645- out [lenout : lenout + lenres ] = result
646- lenout += lenres
642+ if where is None or len (where ) == 2 :
643+ if behaved :
644+ # Fast path
645+ out .schunk .update_data (nchunk , result , copy = False )
647646 else :
648- raise ValueError ("The where condition must be a tuple with one or two elements" )
647+ out [slice_ ] = result
648+ elif len (where ) == 1 :
649+ lenres = len (result )
650+ out [lenout : lenout + lenres ] = result
651+ lenout += lenres
652+ else :
653+ raise ValueError ("The where condition must be a tuple with one or two elements" )
649654
650655 if orig_slice is not None :
651656 if isinstance (out , np .ndarray ):
0 commit comments