tidyverse / purrr

A functional programming toolkit for R
https://purrr.tidyverse.org/
Other
1.26k stars 271 forks source link

Consider removing lifecycle message from `transpose()` #1119

Closed mikkmart closed 3 weeks ago

mikkmart commented 6 months ago

Currently about 99% of the execution time is spent doing lifecycle checks for a simple use-case:

lean_transpose <- function(x) {
  .Call(purrr:::transpose_impl, x, NULL)
}

microbenchmark::microbenchmark(
  lean_transpose(iris),
  purrr::transpose(iris),
  purrr::list_transpose(unclass(iris)),
  times = 11
)
#> Unit: microseconds
#>                                  expr      min        lq        mean   median        uq      max neval cld
#>                  lean_transpose(iris)     20.6     22.55    103.1364     24.0     60.40    765.9    11  a 
#>                purrr::transpose(iris)   5703.3   6054.85   7139.5636   6663.3   7761.35  11357.3    11  a 
#>  purrr::list_transpose(unclass(iris)) 536851.9 563524.55 602074.3182 609531.7 624008.50 690577.0    11   b
hadley commented 1 month ago

Hmmmm, maybe we could cache this so you only get it once per session. Could set the$transpose_signalled to TRUE once it's done.