>>>> "JR" == "Jeff Ryan" <[EMAIL PROTECTED]> >>>> on Wed, 3 Dec 2008 15:22:24 -0600
JR> My 2c: JR> JR> The real issue for me is that this approach to handling S4 objects by JR> altering R functions for the worse is incorrect. (by calling JR> bind_activation) JR> JR> m <- matrix(1:2e6L) # 2 million obs JR> > system.time(cbind(m,m)) JR> user system elapsed JR> 0.027 0.017 0.044 JR> > methods:::bind_activation(TRUE) JR> [1] FALSE JR> JR> # the additional overhead of cbind is now damaging to cbind S3 methods JR> > system.time(cbind(m,m)) JR> user system elapsed JR> 0.043 0.034 0.077 [~175% of the original time] JR> JR> Wouldn't a better near-term approach involve writing S3 methods to dispatch on. JR> JR> > methods:::bind_activation(FALSE) JR> > library(Matrix) JR> > M <- Matrix(1:10) JR> > cbind(M,M) JR> M M JR> [1,] ? ? JR> JR> > cbind.dgeMatrix <- function(..., deparse.level=1) methods:::cbind(..., deparse.level=deparse.level) JR> > cbind(M,M) JR> 10 x 2 Matrix of class "dgeMatrix" JR> [,1] [,2] JR> [1,] 1 1 JR> [2,] 2 2 JR> [3,] 3 3 JR> [4,] 4 4 JR> [5,] 5 5 JR> [6,] 6 6 JR> [7,] 7 7 JR> [8,] 8 8 JR> [9,] 9 9 JR> [10,] 10 10 JR> JR> # this approach "does no harm" to regular S3 methods JR> > system.time(cbind(m,m)) JR> user system elapsed JR> 0.028 0.017 0.045 JR> JR> Obviously this negates part of the S4 dispatch value, but that can be JR> had by calling cbind2 directly. JR> JR> JR> Jeff There is no surprise that the default cbind function is faster because it calls a C routine in contrast with methods:::cbind which reduces the problem "self recursively" to two arguments. if you try the patch I sent in my previous message, you will notice that the problem you mentioned is essentially improved. regards, Yohan ______________________________________________ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel