## ----setup-------------------------------------------------------------------- library(grumpy) library(Rarr) ## ----------------------------------------------------------------------------- x <- matrix(0L, nrow = 1000L, ncol = 1000L) x[300L:400L, 700L:800L] <- seq_len(101L * 101L) f_zarr <- withr::local_tempfile(fileext = ".zarr") Rarr::write_zarr_array(x, f_zarr, chunk_dim = c(100L, 100L), compressor = NULL) ## ----------------------------------------------------------------------------- size <- list.files(f_zarr, full.names = TRUE, recursive = TRUE) |> file.info() |> subset(select = "size") |> sum() size ## ----------------------------------------------------------------------------- library(reticulate) np <- import("numpy") f_npy <- withr::local_tempfile(fileext = ".npy") np$save(f_npy, x) ## ----------------------------------------------------------------------------- microbenchmark::microbenchmark( grumpy = read_npy(f_npy), zarr = read_zarr_array(f_zarr), times = 50L ) .