knitr::opts_chunk$set(collapse = TRUE, comment = "#> ")
library(tidyverse)
library(vctrs)

df <- data.frame(x = 1:10, y = letters[1:10], stringsAsFactors = FALSE)
dfs <- map(1:100, ~ df)

Currently, vec_rbind() is much slower than the alternatives:

bench::mark(
  do.call(rbind, dfs),
  vec_rbind(!!!dfs),
  dplyr::bind_rows(dfs)
)

I've removed the biggest bottlenecks coercing data frames to lists with vec_data(), operating on them, and then restoring with vec_restore(). This avoids the expensive data frame methods. I think further improvement (to get on par with base/dplyr) will require a systematic rewrite in C.

profvis::profvis(vec_rbind(!!!dfs))


r-lib/vctrs documentation built on Oct. 30, 2024, 8:54 a.m.