Re: [julia-users] Immutable vs. Mutable composite types: Trying to understand performance and memory allocations

2016-01-26 Thread Nitin Arora
Thanks. I just opened an issue to improve the docs https://github.com/JuliaLang/julia/issues/14801 On Tuesday, January 26, 2016 at 12:23:30 AM UTC-8, Mauro wrote: > > I think the only time performance of immutables can be better than > mutables, is when they are also isbits. This is the case

Re: [julia-users] Immutable vs. Mutable composite types: Trying to understand performance and memory allocations

2016-01-26 Thread Kristoffer Carlsson
The reason you get allocations is because you are running things in global scope. http://docs.julialang.org/en/release-0.4/manual/performance-tips/#avoid-global-variables Seems immutable would work well for your use case.

Re: [julia-users] Immutable vs. Mutable composite types: Trying to understand performance and memory allocations

2016-01-26 Thread Kristoffer Carlsson
The reason you get allocations is because you are running things in global scope. http://docs.julialang.org/en/release-0.4/manual/performance-tips/#avoid-global-variables Seems immutable would work well for your use case.

Re: [julia-users] Immutable vs. Mutable composite types: Trying to understand performance and memory allocations

2016-01-26 Thread Mauro
I think the only time performance of immutables can be better than mutables, is when they are also isbits. This is the case when all the fields of an immutable are isbits. Note that the compiler if free to either copy or reference immutables as the are immutable. On Tue, 2016-01-26 at 09:19,

Re: [julia-users] Immutable vs. Mutable composite types: Trying to understand performance and memory allocations

2016-01-26 Thread Mauro
> I assume from mutate you mean not changing type of the sub-variable (e.g > "vstate" above) ? I plan to change the values inside that vector but the > vector itself, both in length and type, will remain constant. Yes, then I'd use immutable. However, I don't think it will improve performance

Re: [julia-users] Immutable vs. Mutable composite types: Trying to understand performance and memory allocations

2016-01-26 Thread Nitin Arora
Thanks, I somehow missed that fact while checking for memory allocations. On Monday, January 25, 2016 at 11:59:42 PM UTC-8, Kristoffer Carlsson wrote: > > The reason you get allocations is because you are running things in global > scope. > > >

Re: [julia-users] Immutable vs. Mutable composite types: Trying to understand performance and memory allocations

2016-01-26 Thread Nitin Arora
Okay thanks. But Is it not true that, if I pass the immutable Point type or an array of the same to various functions, then Julia compiler will pass it by copying instead of passing it by reference ? >From the documentation: *"An object with an immutable type is passed around (both in

[julia-users] Immutable vs. Mutable composite types: Trying to understand performance and memory allocations

2016-01-25 Thread Nitin Arora
I have couple of questions ( maybe dumb :-) ) regarding composite types: 1) For a vector of composite type defined as: immutable Point{T<:AbstractFloat} vstate :: Vector{T} # is a vector of length 6 which will be updated during code execution ct :: Vector{T} # is a vector of length

Re: [julia-users] Immutable vs. Mutable composite types: Trying to understand performance and memory allocations

2016-01-25 Thread Yichao Yu
On Tue, Jan 26, 2016 at 12:46 AM, Nitin Arora wrote: > I have couple of questions ( maybe dumb :-) ) regarding composite types: > > 1) For a vector of composite type defined as: > > immutable Point{T<:AbstractFloat} > vstate :: Vector{T} # is a vector of length 6 which

Re: [julia-users] Immutable vs. Mutable composite types: Trying to understand performance and memory allocations

2016-01-25 Thread Nitin Arora
Thanks for the reply. I assume from mutate you mean not changing type of the sub-variable (e.g "vstate" above) ? I plan to change the values inside that vector but the vector itself, both in length and type, will remain constant. Nitin On Monday, January 25, 2016 at 10:23:21 PM UTC-8, Yichao