File tree Expand file tree Collapse file tree 2 files changed +5
-2
lines changed Expand file tree Collapse file tree 2 files changed +5
-2
lines changed Original file line number Diff line number Diff line change 1+ Avoid an unnecessary memory copy when writing Zarr to a local file
Original file line number Diff line number Diff line change @@ -51,15 +51,17 @@ def _put(
5151    if  start  is  not   None :
5252        with  path .open ("r+b" ) as  f :
5353            f .seek (start )
54-             f .write (value .as_numpy_array ().tobytes ())
54+             # write takes any object supporting the buffer protocol 
55+             f .write (value .as_numpy_array ())  # type: ignore[arg-type] 
5556        return  None 
5657    else :
57-         view  =  memoryview (value .as_numpy_array (). tobytes ()) 
58+         view  =  memoryview (value .as_numpy_array ())   # type: ignore[arg-type] 
5859        if  exclusive :
5960            mode  =  "xb" 
6061        else :
6162            mode  =  "wb" 
6263        with  path .open (mode = mode ) as  f :
64+             # write takes any object supporting the buffer protocol 
6365            return  f .write (view )
6466
6567
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments