I would have expected the comprehension to be faster. Is this in global scope? If so you may want to try the speed comparison again where each of these occur in a function body and only depend on function arguments.
On Tue, Jun 16, 2015 at 10:12 AM, Seth <[email protected]> wrote: > I have been using list comprehensions of the form > bar(g, a) = [Pair(x, g) for x in a] and [foo(x) for x in a] > > but recently evaluated bar(g, a) = map(x->Pair(x, g),a) and > map(x->foo(x),a)as substitutes. > > It seems from some limited testing that map is slightly faster than the > list comprehension, but it's on the order of 3-4% so it may just be noise. > Allocations and gc time are roughly equal (380M allocations, ~27000MB, ~6% > gc). > > Should I prefer one approach over the other (and if so, why)? > > Thanks! >
