The OP said that it was the three lines involving arr1, arr2, and arr3 that 
took all the time and allocated lots of memory.  But I believe that the 
lines 

arr3 = arr2
arr2 = arr1

should not allocate memory nor take any significant time to execute because 
they do not involve any copying, but merely arrange for the variable names 
to be associated with already declared arrays.  Correct?

--Peter

On Thursday, December 18, 2014 1:59:26 PM UTC-8, Stefan Karpinski wrote:
>
> Just to be clear (otherwise someone is going to link to this thread and 
> say that Julia insists that you should write long, devectorized code): 
> while writing slightly longer, more explicit code is – for now – sometimes 
> the easiest way to make your code really fast, this is not a Julia mantra 
> nor a philosophical underpinning of the language. We would like, through 
> improved compiler technology, to make the shortest, most convenient way to 
> write something also the fastest. But we won't cheat to accomplish this by 
> doing something hacky that doesn't generalize – and that *is* a 
> philosophical underpinning of the language.
>
> On Thu, Dec 18, 2014 at 3:37 PM, DumpsterDoofus <peter.ri...@gmail.com 
> <javascript:>> wrote:
>
>> Thanks! Doing the updates in place instead of copying tripled speed, and 
>> using a:b instead of [a:b] got another 50% speed increase. It's amazing how 
>> writing longer code can sometimes make things go faster.
>>
>
>

Reply via email to