How fast does & perform?
- To: mathgroup at smc.vnet.net
- Subject: [mg107293] How fast does & perform?
- From: Canopus56 <canopus56 at yahoo.com>
- Date: Mon, 8 Feb 2010 03:35:33 -0500 (EST)
Setting aside the syntax question of the thread "What does & mean?", there appears to be a performance difference between the two syntax forms. Looks like the := form is faster: data = Table[x, {x, (\[Pi]/8), \[Pi], (\[Pi]/512)}] g[x_] := x*Sin[x] Timing[Table[g[data[[k]]], {k, 1, Length[data]}]] 2.71051*10^-17 seconds Timing[Map[g, data]] 0. seconds Timing[Map[g[#] &, data]] 0.016 seconds Timing[Map[#*Sin[#] &, data]] 0.031 seconds Timing[#*Sin[#] & /@ data] 0.032 seconds - Kurt