Skip to content

Resolving functions using R's namespace mechanism can double runtime

3 messages · Dominick Samperi, Seth Falcon, Romain Francois

#
On 4/27/10 1:16 PM, Dominick Samperi wrote:
`::` is a function, so there is going to be overhead.  OTOH, there is no 
reason to pay for the lookup more than once.  For example at startup, 
you could do:

myfoo <- pkgname::foo

And then later call myfoo() and I don't think you will see the added cost.

You can formalize the above approach in package code by renaming 
function in the importFrom directive where I believe you can do:

importFrom(pkgname, myfoo=foo)


+ seth
#
Le 27/04/10 22:16, Dominick Samperi a ?crit :
It would probably help your question if you provide some benchmarks.

a::b is just a shortcut for `::`( a, b ).
Not really. You can :
- resolve once: my_foo <- pkgname::foo
- import the variable into your namespace using the importFrom namespace 
directive.