r-lib / styler

Non-invasive pretty printing of R code
https://styler.r-lib.org
Other
703 stars 70 forks source link

Use stable version of `{purrr}` #1215

Closed IndrajeetPatil closed 2 months ago

IndrajeetPatil commented 2 months ago

Benchmarks:

internal_map_dfr <- function(.x, .f, ...) {
  .f <- purrr::as_mapper(.f, ...)
  res <- purrr::map(.x, .f, ...)
  vctrs::vec_rbind(!!!res)
}

x <- list(
  a = data.frame(x = rnorm(1e6)),
  b = data.frame(y = rnorm(1e6))
)

bench::mark(
  internal_map_dfr(x, ~ .x),
  purrr::map(x, ~ .x) |> purrr::list_rbind()
)
#> # A tibble: 2 × 6
#>   expression                             min median `itr/sec` mem_alloc `gc/sec`
#>   <bch:expr>                          <bch:> <bch:>     <dbl> <bch:byt>    <dbl>
#> 1 internal_map_dfr(x, ~.x)            4.93ms 5.08ms      168.    46.3MB     364.
#> 2 purrr::list_rbind(purrr::map(x, ~.… 4.81ms    5ms      199.    45.8MB     388.

Created on 2024-05-23 with reprex v2.1.0

github-actions[bot] commented 2 months ago

This is how benchmark results would change (along with a 95% confidence interval in relative change) if 9e9d8eca8ffcafdb9441574b873d5f093be55837 is merged into main:

Further explanation regarding interpretation and methodology can be found in the documentation.