Hello,

Thanks. It was difficult to pinpoint, but I was able to make a minimal example. 
It happens only if SummarizedExperiment is pre-loaded. The difference is 0.2 
seconds versus 32 seconds on my modest Windows 10 laptop computer - a 150 times 
slowdown. Can you reproduce it?

library(SummarizedExperiment)

setClassUnion("characterOrMissing", c("character", "missing"))
setClassUnion("integerOrMissing", c("integer", "missing"))
setClass("ParamsSet", representation(A = "characterOrMissing", B = "integer"))
setGeneric("ParamsSet", function(A, B, C, D, E, F, G, H) 
standardGeneric("ParamsSet"))

setMethod("ParamsSet", c("missing", "missing", "missing", "missing", "missing", 
"missing", "missing", "missing"),
function() # Empty constructor
{
  new("ParamsSet", A = 'M', B = 300L)
})

setMethod("ParamsSet", c("characterOrMissing", "integerOrMissing", 
"integerOrMissing", "integerOrMissing",
                         "characterOrMissing", "integerOrMissing", 
"integerOrMissing", "integerOrMissing"),
function(A = c('L', 'M', 'N'), B = 500, C = 100, D, E, F, G, H)
{
  if(missing(A)) A <- 'L' # Mimick match.arg.
  if(missing(B)) B <- 500L # Hack to implement parameter defaults not specified 
by generic.
  if(missing(C)) C <- 100L
  new("ParamsSet", A = A, B = B)
})

system.time(ParamsSet(B = 999L)) # Slow or fast, depending on 
SummarizedExperiment presence.

--------------------------------------
Dario Strbenac
University of Sydney
Camperdown NSW 2050
Australia
_______________________________________________
Bioc-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/bioc-devel

Reply via email to