[R] Execution of R code

Prof Brian Ripley ripley at stats.ox.ac.uk
Wed Jun 25 13:09:18 CEST 2003


I am not sure I fully understand the Qs.

There are two phases.

1) The source code is parsed.
2) The parsed code is evaluated.

If you run code from source() or a file or the command line, it is
parsed and evaluated.  However, evaluating a function assignment makes an 
function object containing the parsed code for the body of a function.

Running code a second time is often faster because of caching of memory
(in the chip's caches and in RAM ratehr than VM). In S-PLUS there are more
layers of caching going on: objects are retrieved from disc and (usually)
cached in memory, and memory allocated for objects can be re-used rather
than re-allocated.

There is no form of pre-compiling to intermediate code on first use (as 
some Java implementations use), although things like that are in Luke
Tierney's long-term plans.

I hope that actually answers your questions.

On Wed, 25 Jun 2003 Ted.Harding at nessie.mcc.ac.uk wrote:

> Greetings Folks,
> 
> When R code (as entered or read from a courced file) is executed,
> is it interpreted from the input form every time having once been
> read in, or do subsequent invocations use an "intermediate"
> (pre-interpreted) form?
> 
> Or, putting it another way, is the execution of R code faster
> second time time round (and later) because the pre-interpretation
> has already been done once and for all?
> 
> [And, for seconds, what is the corresponding situation for S-plus?]
> 
> With thanks,
> Ted.
> 
> 
> --------------------------------------------------------------------
> E-Mail: (Ted Harding) <Ted.Harding at nessie.mcc.ac.uk>
> Fax-to-email: +44 (0)870 167 1972
> Date: 25-Jun-03                                       Time: 10:19:00
> ------------------------------ XFMail ------------------------------
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
> 

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595




More information about the R-help mailing list