Using `::` does add some overhead - on the order of 5-10 microseconds
on my computer. Still, it would take 100,000 calls to add 0.5-1 second
of delay.
microbenchmark(
base::identity(1),
identity(1),
unit = "us"
)
# Unit: microseconds
# expr min lq median uqmax nev
Hi Gabe,
On 05/30/2014 11:34 AM, Gabriel Becker wrote:
This isn't likely to make much difference in most cases, but calling a
function via :: can incur up to about twice the overhead on average
compared to calling an imported function
> fun1
function ()
file_ext("text.txt")
> fun2
function (
On Fri, May 30, 2014 at 9:17 PM, Gábor Csárdi
wrote:
> On Fri, May 30, 2014 at 9:08 PM, Hadley Wickham
> wrote:
>
>> > Finally, now that the use of a NAMESPACE became mandatory (well, this
>> > happened a few years ago), advocating systematic use of foo::whatever()
>> > without explicitly impo
On Fri, May 30, 2014 at 9:08 PM, Hadley Wickham wrote:
> > Finally, now that the use of a NAMESPACE became mandatory (well, this
> > happened a few years ago), advocating systematic use of foo::whatever()
> > without explicitly importing the function sounds a little bit like an
> > heroic act of
> Finally, now that the use of a NAMESPACE became mandatory (well, this
> happened a few years ago), advocating systematic use of foo::whatever()
> without explicitly importing the function sounds a little bit like an
> heroic act of resistance ;-)
I don't think that's at all true - for most other
On 05/30/2014 10:00 AM, Hadley Wickham wrote:
There is at least one subtle consequence to keep in mind when doing
this. Of course, whatever choice you make, if the whatever() function
moves to a different package, this breaks your package.
However, if you explicitly import the function, your pack
On Fri, May 30, 2014 at 6:55 PM, Hervé Pagès wrote:
[...]
> There is at least one subtle consequence to keep in mind when doing
> this. Of course, whatever choice you make, if the whatever() function
> moves to a different package, this breaks your package.
> However, if you explicitly import t
This isn't likely to make much difference in most cases, but calling a
function via :: can incur up to about twice the overhead on average
compared to calling an imported function
> fun1
function ()
file_ext("text.txt")
> fun2
function ()
tools::file_ext("text.txt")
> microbenchmark(fun1(), time
> There is at least one subtle consequence to keep in mind when doing
> this. Of course, whatever choice you make, if the whatever() function
> moves to a different package, this breaks your package.
> However, if you explicitly import the function, your package will
> break at load-time (which is
Hi Hadley,
On 05/30/2014 07:06 AM, Hadley Wickham wrote:
Even more important than choosing between whatever(...)
or foo::whatever(...), you should import that function
from the foo package by putting
importFrom(foo, whatever)
or
import(foo)
in your NAMESPACE file.
The 1st form also ki
> Even more important than choosing between whatever(...)
> or foo::whatever(...), you should import that function
> from the foo package by putting
>
> importFrom(foo, whatever)
>
> or
>
> import(foo)
>
> in your NAMESPACE file.
>
> The 1st form also kind of document what function comes from w
Hi Ronald,
On 05/28/2014 01:46 PM, Ronald Barry wrote:
Greetings,
When using a 'foreign' function (from another package, say function
'whatever' from package 'foo'), you can of course just require the package
and then just have
whatever(...)
in your code. However, I would like to use the
12 matches
Mail list logo