Skip to content
Prev 42631 / 398513 Next

Call and memory

On Fri, 9 Jan 2004, Thomas Lumley wrote:

            
storage.mode(X) <- "double" is the standard paradigm to avoid an copy here 
if not needed (even with .C, which would make two copies of X on entry and 
one on exit).

Both arima() and the Kalman fitering code used by StructTS() makes use of
the ability of .Call to alter its arguments, so the advice given is
definitely right.

It is hard to predict when R will make a copy, not least because from time 
to time we spot an unnecessary copy or add a necessary one.  So if you do 
want .Call to alter its arguments you need to test your assumptions (and 
retest when R is updated).