[Rd] S4 Methods dispatch

John Chambers jmc at r-project.org
Wed Aug 30 15:25:27 CEST 2006


A revision of r-devel 2.4.0 is being committed today with changes to 
method and class management.

The changes are internal but extensive.  All packages that use S4 
methods and classes need to be reinstalled from source to use the new 
version.

The main effects are to speed up method caching and dispatch, and to fix 
some problems with selecting inherited methods.  The new design is also 
cleaner, so we can experiment more easily in the future with changes for 
efficiency or semantics.

The change will mostly be noticeable in attaching packages with many 
methods.  The CPU time for attaching package Matrix, for example, goes 
down by about a factor of 7 compared to R 2.3.1, timed on a Mac G5.

The other major change is that now _all_ inherited methods are examined 
and one of the closest matches is chosen.  The old selection took the 
first candidate found, so the current version is better defined, and 
will also let us experiment with various tuning & strategies.

There is a draft paper describing method selection at
  http://developer.r-project.org/howMethodsWork.pdf
(It's a document in progress, so go back in a few days for a revised 
version.)

If a package uses inheritance for method selection with multiple 
arguments, there may well be changes in behavior.  We found examples in 
both methods itself and in Matrix that needed attention.

John



More information about the R-devel mailing list