R6
R6 copied to clipboard
Improve test for Lists vs. environments, and $ vs. [[
The example here: https://github.com/r-lib/R6/blob/507867875fdeaffbe7f7038291256b798f6bb042/vignettes/Performance.Rmd#L712-L723
is too trivial to show the actual differences. A better example would be
lst <- as.list(sample(letters))
names(lst) <- unlist(lst)
env <- new.env()
for (x in lst) assign(x, x, envir=env)
mb_summary(microbenchmark(
lst = lst$x,
env = env$x,
lst[['x']],
env[['x']]
))
which gives in my computer:
name median
1 lst 0.6345
2 env 0.2850
3 lst[["x"]] 0.4085
4 env[["x"]] 0.1960