Skip to content

Conversation

@DavisVaughan
Copy link
Member

Part of #1933

In vec_is_unspecified(), we no longer check directly against the ATTRIB() pointer when we have an actual <vctrs_unspecified> object. I see no discernible difference between doing that and just using Rf_inherits()

cross::bench_branches({
  library(vctrs)
  is_unspecified <- vctrs:::is_unspecified
  x <- unspecified(1e6)
  bench::mark(is_unspecified(x))
})
#> # A tibble: 2 × 7
#>   branch                expression             min   median `itr/sec` mem_alloc `gc/sec`
#>   <chr>                 <bch:expr>        <bch:tm> <bch:tm>     <dbl> <bch:byt>    <dbl>
#> 1 feature/no-set-object is_unspecified(x)    123ns    205ns  4633428.        0B        0
#> 2 main                  is_unspecified(x)    164ns    205ns  4248652.        0B        0

cross::bench_branches({
  library(vctrs)
  is_unspecified <- vctrs:::is_unspecified
  y <- rep(FALSE, 1e6)
  bench::mark(is_unspecified(y))
})
#> # A tibble: 2 × 7
#>   branch                expression             min   median `itr/sec` mem_alloc `gc/sec`
#>   <chr>                 <bch:expr>        <bch:tm> <bch:tm>     <dbl> <bch:byt>    <dbl>
#> 1 feature/no-set-object is_unspecified(y)    164ns    205ns  4316017.        0B        0
#> 2 main                  is_unspecified(y)    164ns    205ns  4166605.        0B        0

cross::bench_branches({
  library(vctrs)
  is_unspecified <- vctrs:::is_unspecified
  z <- rep(NA, 1e6)
  bench::mark(is_unspecified(z))
})
#> # A tibble: 2 × 7
#>   branch                expression             min   median `itr/sec` mem_alloc `gc/sec`
#>   <chr>                 <bch:expr>        <bch:tm> <bch:tm>     <dbl> <bch:byt>    <dbl>
#> 1 feature/no-set-object is_unspecified(z)    564µs    571µs     1739.        0B        0
#> 2 main                  is_unspecified(z)    564µs    585µs     1706.        0B        0

@DavisVaughan DavisVaughan merged commit e192e75 into main Dec 15, 2025
13 checks passed
@DavisVaughan DavisVaughan deleted the feature/no-set-object branch December 15, 2025 15:57
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