Reviewing @avik Sengupta’s book «Julia High Performance» 2nd edition, it says that performance of functions with positional arguments is better than those with keyword (named) arguments, giving the following example:
using BenchmarkTools
named_param(x; y=1, z=1) = x^y + x^z
pos_param(x,y,z) = x^y + x^z
@btime named_param(4; y=2, z=3)
@btime pos_param(4, 2, 3)
Sengupta’s book reports 8.306ns
for named_param
and 5.548ns
for pos_param
:
but running the same code in my own computer I get the opposite:
Any explanation for this?