inst/doc/design.R

## -----------------------------------------------------------------------------
f <- tempfile(fileext = ".npy")
np <- reticulate::import("numpy")
x <- np$random$rand(1000L, 1000L)
np$save(f, x)

microbenchmark::microbenchmark(
  reticulate = {
    x <- np$load(f)
  },
  grumpy = {
    x <- grumpy::read_npy(f)
  },
  times = 1e3
)

## On platform that support it, lazy reading offers even better performance for large files
if (Sys.info()[["sysname"]] %in% c("Linux", "Darwin")) {
  microbenchmark::microbenchmark(
    reticulate = {
      x <- np$load(f)
    },
    grumpy = {
      x <- grumpy::read_npy(f, lazy = TRUE)
    },
    times = 1e3
  )
}

Try the grumpy package in your browser

Any scripts or data that you put into this service are public.

grumpy documentation built on Nov. 16, 2026, 5:07 p.m.