Skip to main content
Became Hot Network Question
Tweeted twitter.com/StackMma/status/1288127100902240258
deleted 5 characters in body
Source Link
Sjoerd Smit
  • 24.8k
  • 48
  • 80

It seems like there is some sort of evaluation overhead related to the ResourceFunction wrapper that I'd like to avoid. This seemsis especially pronounced for functions with attributes. Take, for example, SymbolQ, which is essentially a wrapper for a built-in function from the Developer context:

Attributes[mySymbolQ] = {HoldAllComplete};
mySymbolQ[x_] := Developer`HoldSymbolQ[x];
x = 1;
ResourceFunction["SymbolQ"][x] // RepeatedTiming
mySymbolQ[x] // RepeatedTiming

{0.00068, True}

{5.2*10^-7, True}

Is there an easy way to avoid this slowdown without having to copy the source code from the resource function completely?

It seems like there is some sort of evaluation overhead related to the ResourceFunction wrapper that I'd like to avoid. This seems especially pronounced for functions with attributes. Take, for example, SymbolQ, which is essentially a wrapper for a built-in function from the Developer context:

Attributes[mySymbolQ] = {HoldAllComplete};
mySymbolQ[x_] := Developer`HoldSymbolQ[x];
x = 1;
ResourceFunction["SymbolQ"][x] // RepeatedTiming
mySymbolQ[x] // RepeatedTiming

{0.00068, True}

{5.2*10^-7, True}

Is there an easy way to avoid this slowdown without having to copy the source code from the resource function completely?

It seems like there is some sort of evaluation overhead related to the ResourceFunction wrapper that I'd like to avoid. This is especially pronounced for functions with attributes. Take, for example, SymbolQ, which is essentially a wrapper for a built-in function from the Developer context:

Attributes[mySymbolQ] = {HoldAllComplete};
mySymbolQ[x_] := Developer`HoldSymbolQ[x];
x = 1;
ResourceFunction["SymbolQ"][x] // RepeatedTiming
mySymbolQ[x] // RepeatedTiming

{0.00068, True}

{5.2*10^-7, True}

Is there an easy way to avoid this slowdown without having to copy the source code from the resource function completely?

Source Link
Sjoerd Smit
  • 24.8k
  • 48
  • 80

How can I avoid performance losses from ResourceFunction?

It seems like there is some sort of evaluation overhead related to the ResourceFunction wrapper that I'd like to avoid. This seems especially pronounced for functions with attributes. Take, for example, SymbolQ, which is essentially a wrapper for a built-in function from the Developer context:

Attributes[mySymbolQ] = {HoldAllComplete};
mySymbolQ[x_] := Developer`HoldSymbolQ[x];
x = 1;
ResourceFunction["SymbolQ"][x] // RepeatedTiming
mySymbolQ[x] // RepeatedTiming

{0.00068, True}

{5.2*10^-7, True}

Is there an easy way to avoid this slowdown without having to copy the source code from the resource function completely?