[Rd] Speeding up library loading

Ali - saveez at hotmail.com
Mon Apr 25 23:05:15 CEST 2005



>>Lazy loading just converts an object into a small instruction to load the 
>>object. If the object was already small, there's no advantage to that.  
>>It's mainly designed to avoid memory use (some rarely used objects can be 
>>gigantic).
>
>From a design point of view the reason is that this isn't the problem lazy 
>loading is trying to solve. We didn't have a problem with packages that 
>have huge number of small objects, but we did have a problem with packages 
>that had a moderate number of moderately large objects.
>
>In addition, trying to optimize performance is not usually a good idea 
>unless you can measure the performance of different implementations on real 
>applications, and we didn't have applications like that.

Assume 100 C++ classes each class having 100 member functions. After 
wrapping these classes into R, if the wrapping design is class-oriented we 
should have like 100 objects. At the same time, if the wrapping design is 
function-oriented we have like 10`000 objects which are too lazy for lazy 
loading.

I have tried wrapping exactly the same classes by R.oo based on S3 and the 
outcome package was much faster in both installation and loading. The 
package went slow once I tried it with S4. I guess R.oo makes the package 
more class-oriented while S4 object-orientation is really function-oriented 
causing all this friction in installation and loading.

Is there any way to ask R to lazy-load each object as a 'bundle of S4 
methods with the same class'?



More information about the R-devel mailing list