You will have to load my package github/jmichel7/Gapjm.jl
to run the code below, but my question is simple enough.
julia> W=WeylGroup(:A,2)
WeylGroup(:A,2)
julia> Pol(:q)
q
julia> H=hecke(W,(q,-q^-1),q)
Hecke(WeylGroup(:A,2),(q, -q^-1),q)
julia> d=[one(H.W)=>one(Pol{Int})]
1-element Array{Pair{Perm{UInt8},Pol{Int64}},1}:
{UInt8}() => 1
julia> @btime HeckeTElt($d,$H)
1.517 ΞΌs (15 allocations: 816 bytes)
T()
In the code above, I construct fairly complex objects d
and H
but then just call a constructor:
struct HeckeTElt{P,C}<:HeckeElt{P,C}
d::SortedPairs{P,C}
H::HeckeAlgebra{C,<:CoxeterGroup}
end
There is no other constructor function, and the arguments are of the right type:
julia> typeof(d)
Array{Pair{Perm{UInt8},Pol{Int64}},1}
julia> SortedPairs
Array{Pair{K,V},1} where V where K
julia> typeof(H)
HeckeAlgebra{Pol{Int64},WeylGroup}
So why on earth does my constructor allocates 15 objects? I thought from various discussions that having a big object H in my struct
takes no more memory that a reference to it in another language. Actually sizeof()
returns 16 on my object. So why is the constructor so costly?