Hi,

I was experimenting with the new 0.5 features and they are great! But to my 
surprise,
the generator syntax doesn't work as I'm expecting. Let's say I want to 
calculate
some summation. With the old syntax I could do

@time sum([2*t for t in 1:2:100])
  0.015104 seconds (13.80 k allocations: 660.366 KB)

that allocates the array within the summation. Now I thought this would a 
prime example
where the memory overhead could be decreased by using the new notation i.e.

@time sum(2*t for t in 1:2:100)
  0.019215 seconds (18.98 k allocations: 785.777 KB)

,but generator syntax performs slightly worse. Also if we want find the 
maximum we would do

julia> @time maximum([2*t for t in 1:2:100])
  0.015182 seconds (12.90 k allocations: 606.166 KB)
198

julia> @time maximum(2*t for t in 1:2:100)
  0.019935 seconds (18.74 k allocations: 772.180 KB)
198

Have I understood the new generator syntax incorrectly or should the new 
syntax perform
better in these code snippet examples?






Reply via email to