Skip to content

Conversation

DavisVaughan
Copy link
Member

@DavisVaughan DavisVaughan commented Oct 18, 2025

Again avoiding the allocation of rlang_env_dots_list()

pkgs <- tibble::tribble(
  ~vctrs             , ~rlang        ,
  "vctrs"            , "rlang"       ,
  "r-lib/vctrs#2071" , "r-lib/rlang" ,
)

cross::bench_versions(pkgs = pkgs, {
  library(vctrs)
  x <- as.list(1:1e6)
  bench::mark(vec_ptype_common(!!!x))
})
#> # A tibble: 2 × 7
#>   pkg                      expression    min median `itr/sec` mem_alloc `gc/sec`
#>   <chr>                    <bch:expr> <bch:> <bch:>     <dbl> <bch:byt>    <dbl>
#> 1 vctrs, rlang             vec_ptype… 39.4ms 39.9ms      25.1    7.63MB     4.56
#> 2 r-lib/vctrs#2071, r-lib… vec_ptype… 23.9ms 24.3ms      41.1    3.27KB     0

# When a `ptype` is passed through
cross::bench_versions(pkgs = pkgs, {
  library(vctrs)
  x <- as.list(1:1e6)
  bench::mark(vec_ptype_common(!!!x, .ptype = integer()))
})
#> # A tibble: 2 × 7
#>   pkg                      expression    min median `itr/sec` mem_alloc `gc/sec`
#>   <chr>                    <bch:expr> <bch:> <bch:>     <dbl> <bch:byt>    <dbl>
#> 1 vctrs, rlang             vec_ptype… 4.87ms 5.09ms      185.    7.63MB     43.7
#> 2 r-lib/vctrs#2071, r-lib… vec_ptype… 1.07µs 1.19µs   694085.    3.06KB      0

Created on 2025-10-18 with reprex v2.1.1

@DavisVaughan DavisVaughan merged commit 3d8ed48 into main Oct 20, 2025
14 checks passed
@DavisVaughan DavisVaughan deleted the feature/vec-ptype-common-list2 branch October 20, 2025 16:20
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.

1 participant