Skip to content
Prev 43106 / 398502 Next

storage.mode and argument duplication

In R, storage.mode<- is an interpreted function that calls as.double (in 
your case) and copies attributes across so it is definitely worse than the 
second.

Is x$one usually double?  If so then

.Fortran("foo", if(is.double(x$one)) x$one else as.double(x$one), ...)

would save a copy.

Does your Fortran code change that argument?  As is .Fortran will make a
copy on the way in and on the way out. I think you should be able to use
DUP=FALSE, but if x$one is changed you need the as.double to make a copy.
I would not be worrying about anything up I had avoided the copies from
.Fortran.  My inclination would be to write a .Call wrapper to get full
control.
On Wed, 21 Jan 2004, Paul Gilbert wrote: