On Thu, 27 May 2004 22:55:20 +0200, "Torsten Steuernagel"
<[EMAIL PROTECTED]> wrote :


>> 2. Is it true
>> that one can gain execution speed by accessing slots using the
>> function slots(object,name,check=FALSE)<-value would speed up
>> execution?
>
>Try this:
>
>> get("@<-")
>function (object, name, value) 
>{
>    arg <- substitute(name)
>    if (is.name(arg)) 
>        name <- as.character(arg)
>    "slot<-"(object, name, TRUE, value)
>}
>
>So "@<-" actually calls "slot<-". Using "slot<-" instead, you save the 
>additional overhead the call to "@<-" introduces. If there will be a real 
>performance gain in replacing "@<-" certainly depends on what you're 
>doing.

I'd advise against doing this kind of optimization.  It will make your
code harder to maintain, and while it might be faster today, if "@<-"
is really a major time sink, it's an obvious candidate for
optimization in R, e.g. by making it .Internal or .Primitive.  When
that happens, your "optimized" code will likely be slower (if it even
works at all).

Duncan Murdoch

______________________________________________
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

Reply via email to