>>>>> Martin Maechler >>>>> on Thu, 16 Sep 2021 17:48:41 +0200 writes:
>>>>> Alexander Kaever >>>>> on Thu, 16 Sep 2021 14:00:03 +0000 writes: >> Hi, >> It seems like a try(do.call(f, args)) can be very slow on error depending on the args size. This is related to a complete deparse of the call using deparse(call)[1L] within the try function. How about replacing deparse(call)[1L] by deparse(call, nlines = 1)? >> Best, >> Alex > an *excellent* idea! > I have checked that the resulting try() object continues to contain the > long large call; indeed that is not the problem, but the > deparse()ing *is* as you say above. > {The experts typically use tryCatch() directly, instead of try() , > which may be the reason other experienced R developers have not > stumbled over this ...} > Thanks a lot, notably also for the clear repr.ex. below. > Best regards, > Martin OTOH, I find so many cases of deparse(*)[1] (or similar) in R's own sources, I'm wondering if I'm forgetting something ... and using nlines=* is not always faster & equivalent and hence better ?? Martin >> Example: >> fun <- function(x) { >> stop("testing") >> } >> d <- rep(list(mtcars), 10000) >> object.size(d) >> # 72MB >> system.time({ >> try(do.call(fun, args = list(x = d))) >> }) >> # 8s ______________________________________________ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel