[Rd] .Fortran to .Call

Therneau, Terry M., Ph.D. therne@u @end|ng |rom m@yo@edu
Mon Dec 28 13:46:43 CET 2020


Roger,
  Over the years I have converted many of the .C calls in the survival package to .Call.  
As others have said, the big advantage is memory footprint.  I did it because there are a 
few users who call survfit or coxph with really large data sets, and not copying the data 
can be the difference between success and failure (run out of memory).  Like you, my 
experience has been that if there is enough memory, then the time required for .C or 
.Fortran to make the data copy is minimal.   Don't make the change in order to gain 
compute speed.

The downside to .Call is that R then makes the (dangerous) assumption that you know what 
you are doing.  That is, vectors/matrices that are passed in to the function will NOT have 
new data values written into them, unless you have taken the necessary steps.   Breaking 
the promise can lead to program failures that are very hard to track down.

-- 
Terry M Therneau, PhD
Department of Health Science Research
Mayo Clinic
therneau using mayo.edu

"TERR-ree THUR-noh"


	[[alternative HTML version deleted]]



More information about the R-devel mailing list