-
Notifications
You must be signed in to change notification settings - Fork 73
Closed
Description
Both as_list_of.list() and as_list_of.vctrs_list_of() call list_of(!!!x, .ptype = .ptype) which directly collects the input again via list2(). As profvis shows this roundtrip doubles to triples the time required
vctrs:::as_list_of.list <- function (x, ..., .ptype = NULL) {
list_of(!!!x, .ptype = .ptype)
}
vctrs:::list_of <- function (..., .ptype = NULL) {
args <- list2(...)
ptype <- vec_ptype_common(!!!args, .ptype = .ptype)
if (is.null(ptype)) {
abort("Could not find common type for elements of `x`.")
}
x <- map(args, vec_cast, to = ptype)
new_list_of(x, ptype)
}I don't know if r-lib/rlang#937 would help to speed this up but it would be great if one could avoid this performance loss which feels quite unnecessary.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
