[Rd] Slow try in combination with do.call
Martin Maechler
m@ech|er @end|ng |rom @t@t@m@th@ethz@ch
Thu Sep 16 17:48:41 CEST 2021
>>>>> 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
> 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
> Unsere Informationen zum Datenschutz finden Sie hier<https://www.evotec.com/de/about/site-information/datenschutzbestimmungen>.
> Evotec International GmbH, Hamburg. Amtsgericht Hamburg HRB 72242
> Geschäftsführung: Dr. Cord Dohrmann, Dr. Craig Johnstone, Enno Spillner
> STATEMENT OF CONFIDENTIALITY.
> This email and any attachments may contain confidential, proprietary, privileged and/or private information.
> If received in error, please notify us immediately by reply email and then delete this email and any attachments from your system. Thank you.
> ______________________________________________
> R-devel using r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
More information about the R-devel
mailing list