From phgrosjean at sciviews.org  Sun Oct 17 19:32:10 2004
From: phgrosjean at sciviews.org (Philippe Grosjean)
Date: Sun Oct 17 19:32:31 2004
Subject: [Rd] Lazy loading - importance of NAMESPACE
In-Reply-To: <Pine.LNX.4.44.0410171752250.17145-100000@gannet.stats>
Message-ID: <200410171732.i9HHWBJl022119@outmx008.isp.belgacom.be>

 

> -----Original Message-----
> From: r-devel-bounces@stat.math.ethz.ch 
> [mailto:r-devel-bounces@stat.math.ethz.ch] On Behalf Of Prof 
> Brian Ripley
> Sent: Sunday, October 17, 2004 7:11 PM
> To: Philippe Grosjean
> Cc: r-devel@stat.math.ethz.ch
> Subject: Re: [Rd] Lazy loading - importance of NAMESPACE
> 
> I think you are leaping to a conclusion from a single 
> example.  Lots of things have changed in 2.0.0 and you are 
> repeatedly attributing symptoms to lazy loading without any 
> real evidence.
> 
> I have tested several hundred examples with and without lazy 
> loading, and I have seen no dramatic changes caused by lazy 
> loading.  I have seen dramatic changes caused by the way the 
> DESCRIPTION file is interpreted, and I did stress the 
> importance of getting that right.

This is because I changed nothing in DESCRIPTION between the two, in my
case. But you are right, I don't have your experience, and I barely
understand the new loading mechanism... thus the reason of several messages
I send to r-help, recently.

I attributed this to lazy loading because it is the major change from R
1.9.1 to R 2.0.0... But again, you are right that other changes were
introduced.

It remains that, without namespace, my package loaded about 30 times slower
than with it. It would be interesting to know why, don't you think so?

Best,

Philippe Grosjean

 
> On Sun, 17 Oct 2004, Philippe Grosjean wrote:
> 
> > Hello all,
> > 
> > Following a question in r-help, where I was wondering why my large 
> > package with lots of "Depends:" did load so slowly (almost 
> 30 sec in 
> > lazy loading in R 2.0.0 under Win XP, for 3.4 sec in R 1.9.1 on the 
> > same machine), I discovered that a correct namespace changes 
> > everything: with the namespace added, loading of my package 
> drops to 
> > circa 1 sec, which is more that three times faster than in R 1.9.1 
> > without lazy loading,... and about 30 times faster than 
> without the namespace in R 2.0.0!
> 
> You are not comparing like with like, AFAICS.  In 1.9.1 you 
> were not loading all the dependent packages. In 2.0.0 you 
> were.  If you add a NAMESPACE, nothing changed.  If you 
> replace Depends: by Imports: you don't need to initialize all 
> the dependent packages, and that may well save you a lot of 
> time (for example there is no search for and cacheing of S4 methods).
> 
> But none of this has anything whatsoever to do with lazy loading!
> 
> > First of all, congratulation for implementing lazy loading!
> > 
> > Second, I look in the documentation, and in the Brian 
> Ripley's article 
> > in R News 2/2004, and I found nowhere a place where the 
> importance of 
> > namespace is stressed for lazy loading (although Brian 
> Ripley explains 
> > in several places differences in lazy loading with and without 
> > namespace). I think it is something important and, unless I 
> miss it in 
> > the documentation, it would be useful to tell somewhere that a 
> > namespace is strongly recommended in conjonction with lazy 
> loading...
> > 
> > Finally, a question:
> > >From R News 2/2004 p. 30: "a 'Imports:' field for packages whose 
> > >namespaces
> > are used but do not need to be attached." OK, functions in these 
> > namespaces are available to me, without attaching the package.
> 
> They are not.  They are available to functions in your 
> package's namespace.
> 
> > Now, if I need to attach
> > these packages at a later time because I will use some of their 
> > functions from the command line, then, is this package 
> referred twice 
> > (once in my package environment, once attached to the 
> search path)? If 
> > yes, what is the drawback in term of ressources and speed 
> ('Imports' 
> > versus 'Depends', both in loading, and in use of such a package)?
> 
> That makes no sense to me.  A package should be named in 
> either Imports or Depends and not both.  For you to access 
> it, you need to call library().  That does not load another 
> copy of the namespace, and the total amount of work is 
> essentially the same as if you called library() on it before 
> your own package (which is what Depends; will do).  Does that 
> answer the question you mean to ask?
> 
> -- 
> Brian D. Ripley,                  ripley@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
> 
> ______________________________________________
> R-devel@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
> 
>


[Rd] Lazy loading - importance of NAMESPACE
Philippe Grosjean