The speedups are both via the REPL (global scope?) and inside a module. I 
did a code_native on both - results are 
here: https://gist.github.com/sbromberger/b5656189bcece492ffd9.



On Wednesday, June 17, 2015 at 9:56:22 AM UTC-5, Stefan Karpinski wrote:
>
> 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] 
> <javascript:>> 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!
>>
>
>

Reply via email to