[julia-users] why so much faster with a global than a local vec?

2015-07-03 Thread Scott Jones
In the local case, it is having to allocate, populate, and then at some point garbage collect that array. That is why using a const is much faster.

Re: [julia-users] why so much faster with a global than a local vec?

2015-07-03 Thread Stefan Karpinski
The first one creates a new array object every time it runs. It's a fairly sophisticated analysis to prove that the array never escapes and is never modified and can therefore be reused. On Fri, Jul 3, 2015 at 2:21 PM, Jeffrey Sarnoff jeffrey.sarn...@gmail.com wrote: I wrote a range limited

[julia-users] why so much faster with a global than a local vec?

2015-07-03 Thread Jeffrey Sarnoff
I wrote a range limited isa_leapyear(year) good in 1800..2200. Your look is appreciated; I do not understand this: The first version runs 50x more slowly than the second version. The first is better practice, is there a way to make it behave? They differ only in placing the bit table (local vs

Re: [julia-users] why so much faster with a global than a local vec?

2015-07-03 Thread Yichao Yu
On Fri, Jul 3, 2015 at 8:37 AM, Stefan Karpinski ste...@karpinski.org wrote: The first one creates a new array object every time it runs. It's a fairly sophisticated analysis to prove that the array never escapes and is never modified and can therefore be reused. Also, in general, a global