Skip to content

[[ subsetting much slower than $ #780

@ebein

Description

@ebein

Starting with tibble 3.0.0, column subsetting using [[ is much slower than $. This causes slowdowns in functions that call [[ many times, for example data.matrix on a wide tibble.

df <- tibble::tibble(x = 1)

bench::mark(
  dollar = df$x,
  bracket = df[["x"]],
  iterations = 1000
)
#> # A tibble: 2 x 6
#>   expression      min   median `itr/sec` mem_alloc `gc/sec`
#>   <bch:expr> <bch:tm> <bch:tm>     <dbl> <bch:byt>    <dbl>
#> 1 dollar        6.8us    8.1us   100956.    7.96KB      0  
#> 2 bracket     190.3us  211.2us     3998.  165.09KB     12.0

Created on 2020-06-03 by the reprex package (v0.3.0)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugan unexpected problem or unintended behaviorperformance 🏎️

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions