If you use `type` then it gets stored by reference, if you use `immutable` it 
gets packed as you are expecting.

--Tim

On Saturday, November 28, 2015 02:24:24 AM bernhard wrote:
> I find the totalsizeof Module very helpful for such things:
> https://gist.github.com/avitale/0070b629b89350b39c21#file-totalsize-jl
> 
> But in this case I am actually a little bit confused by the output of the
> code below. There is barely and difference between UInt8 and Int128 Maybe
> there are some issues in my code...
> 
> type A{T<:Integer}
>     A1::T
>     A2::T
> function A()
> return new(one(T),one(T))
> end
> end
> 
> using Totalsizeof
> 
> n=1000
> @show totalsizeof(Array(A{UInt8},n))
> @show totalsizeof(Array(A{Int64},n))
> @show totalsizeof(Array(A{Int128},n))
> 
> t=Int128
> s=Array(A{t},n);
> totalsizeof(s)
> fill!(s,A{t}());
> totalsizeof(s)
> 
> t=UInt8
> s=Array(A{t},n);
> totalsizeof(s)
> fill!(s,A{t}());
> totalsizeof(s)
> 
> Am Samstag, 28. November 2015 11:03:40 UTC+1 schrieb Aleksandr Mikheev:
> > Oh, really thank you, Eric. Now I see. One additional question, if
> > possible.
> > 
> > If I use something like this:
> > 
> > type A
> > 
> >       A1::Int64
> >       A2::Int64
> > 
> > end
> > 
> > I can expect that one element of type A will occupy 128 (2*64) bits. But
> > will happen in this situation?
> > 
> > type A{T<:Integer}
> > 
> >     A1::T
> >     A2::T
> > 
> > end
> > 
> > 
> > 
> > I mean, if I made
> > 
> > 
> > s = Vector{A}(N)
> > 
> > , how much space would it cost me?
> > 
> > Thank you in advance.

Reply via email to