Re: [julia-users] packaging parameters for functions revisited

2014-05-30 Thread Mike Innes
You don't seem to have tried keyword arguments – these are usually the best
option if you have a large set of parameters to pass a single function.
They may not fit your use case but they might be interesting to benchmark
at least.


On 30 May 2014 10:42, Jon Norberg jon.norb...@ecology.su.se wrote:

 There have been several posts about this, so I tried to compile what I
 could find to compare speed and pretty coding:


 http://nbviewer.ipython.org/urls/dl.dropboxusercontent.com/u/38371278/Function%20parms%20passing%20speed%20test.ipynb

 Best speed is assigning values or variables inside the function
 Second best is reassigning parameters from array for each parameter. The
 @pack/@unpack macro also is pretty fast and much prettier
 Third best is separate parameters and global assignment (longer function
 call code if many parameters or/and just no no to use global?)
 Slowest is using indexed array as parameters in function (but this is ugly
 to read) and immutable types

 So I am wondering, did I miss any that improve speed/prettiness?

 Best, Jon






Re: [julia-users] packaging parameters for functions revisited

2014-05-30 Thread Jon Norberg
Do you mean using a dict to pack/unpack them?

function f(x; args...)
###
end

where args is a dict?


Re: [julia-users] packaging parameters for functions revisited

2014-05-30 Thread cnbiz850

Thanks very much for the summary.

It is very interesting that assignFromArray is much faster than 
indexedArray.  Can anyone explain why?


On 05/30/2014 05:42 PM, Jon Norberg wrote:
There have been several posts about this, so I tried to compile what I 
could find to compare speed and pretty coding:


http://nbviewer.ipython.org/urls/dl.dropboxusercontent.com/u/38371278/Function%20parms%20passing%20speed%20test.ipynb

Best speed is assigning values or variables inside the function
Second best is reassigning parameters from array for each parameter. 
The @pack/@unpack macro also is pretty fast and much prettier
Third best is separate parameters and global assignment (longer 
function call code if many parameters or/and just no no to use global?)
Slowest is using indexed array as parameters in function (but this is 
ugly to read) and immutable types


So I am wondering, did I miss any that improve speed/prettiness?

Best, Jon