Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use stable version of {purrr} #1215

Merged
merged 2 commits into from
May 23, 2024
Merged

Use stable version of {purrr} #1215

merged 2 commits into from
May 23, 2024

Conversation

IndrajeetPatil
Copy link
Collaborator

@IndrajeetPatil IndrajeetPatil commented May 23, 2024

Benchmarks:

  • map_dfr() vs map() + list_rbind()
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

@IndrajeetPatil IndrajeetPatil changed the title WIP: Use stable version of {purrrr} WIP: Use stable version of {purrr} May 23, 2024
Copy link
Contributor

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

  • ✔️cache_applying: 155ms -> 156ms [-1.65%, +1.95%]
  • ✔️cache_recording: 523ms -> 525ms [-0.28%, +1.17%]
  • ✔️without_cache: 993ms -> 994ms [-0.22%, +0.45%]

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

@IndrajeetPatil IndrajeetPatil marked this pull request as ready for review May 23, 2024 16:44
@IndrajeetPatil IndrajeetPatil changed the title WIP: Use stable version of {purrr} Use stable version of {purrr} May 23, 2024
@@ -10,12 +10,6 @@ lead <- function(x, n = 1L, default = NA) {
c(x[-seq_len(n)], rep(default, n))
}


arrange <- function(.data, ...) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not used anywhere.

Copy link
Collaborator

@lorenzwalthert lorenzwalthert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good simplification, thanks. Not sure 1.0.2 is the first release that has this functionality, but since it's already a year old, I guess we can require it without causing people troubles...

@IndrajeetPatil IndrajeetPatil merged commit ad1cac1 into main May 23, 2024
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants