There are two points: (1) the problem isn't the lookup, it's type inference 
(see https://github.com/JuliaLang/julia/issues/524) which can prevent Julia 
from generating fast code, and (2) even if in this case it doesn't matter, 
it might later on, so let's recommend some good habits.

Daniel points out using `const` with the global definition, which is 
another valid approach.

On Thursday, July 31, 2014 11:28:26 AM UTC-5, Ivar Nesje wrote:
>
> Patrick, that is wrong. You don't spend a significant portion of 3 seconds 
> looking up a global variable 10 times.
>
> kl. 18:25:25 UTC+2 torsdag 31. juli 2014 skrev Patrick O'Leary følgende:
>>
>> On Thursday, July 31, 2014 10:38:33 AM UTC-5, Neal Becker wrote:
>>>
>>> Attached is my 1st attempt at julia, it is a simple FIR filter, which I 
>>> translated from my c++ version. 
>>>
>>> It is benchmarking about 10x slower than python wrapped c++ version. 
>>>
>>> Any suggestions?
>>
>>
>> Your variable `g` is in global scope, and used in the `timeit()` 
>> function, so that's a likely candidate (see 
>> http://julia.readthedocs.org/en/latest/manual/performance-tips/#avoid-global-variables).
>>  
>> Try defining `g` inside `timeit()`. 
>>
>

Reply via email to