DavisVaughan · GitHub

And break group_data.data.frame() into multiple lines

This is used by compute_by() in the common case of an ungrouped data frame with no .by argument, so it is worth it to make it faster here:

library(dplyr)
df <- tibble(x = 1:5)
bench::mark(group_data(df))
# Main
#> # A tibble: 1 × 6
#>   expression          min   median `itr/sec` mem_alloc `gc/sec`
#>   <bch:expr>     <bch:tm> <bch:tm>     <dbl> <bch:byt>    <dbl>
#> 1 group_data(df)    155µs    173µs     5235.     179KB     8.19
# This PR
#> # A tibble: 1 × 6
#>   expression          min   median `itr/sec` mem_alloc `gc/sec`
#>   <bch:expr>     <bch:tm> <bch:tm>     <dbl> <bch:byt>    <dbl>
#> 1 group_data(df)   22.5µs   24.8µs    37684.     105KB     11.3

Created on 2023-02-17 with reprex v2.0.2.9000

Read the original on github.com ↗