You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The performance of Vector{GapObj}(L) is disappointing. I think it is because of the IdDict we create and maintain, but for nought, at least in this case. Also note how collect is the fastest, but returns a suboptimal type.
In this particular case, one can do quite a bit better:
julia> function f(x::GapObj) v=Vector{GapObj}(undef,length(x)); for i in 1:length(x) v[i]=L[i] end ; return v end
f (generic function with 1 method)
julia> @btime typeof(f(L))
261.013 ns (1 allocation: 112 bytes)
Vector{GapObj} (alias for Array{GapObj, 1})
Perhaps we can set up variants of our conversions which perform faster in "such" cases. Where it remains to be settled what exactly "such" cases are.... coming to mind are certainly:
T{S} where T is a container like Vector, Set, ... and S either GapObj or GAP.Obj or Int.
it could also be done for T{BigInt} or T{fmpz} but then it'd be a tradeoff in performance vs. memory usage, at least in principle. But it might actually better here, as not all "end users" may expect aliasing in these cases, and if someone starts to modify entries in the result in-place, they might be surprised... ?
Even if we can't solve this in general, I think that at least the T{GapObj} case is important enough to deserve special treatment here. I.e. special methods for Vector{GapObj}(x::GapObj) and perhaps also for collect(x::GapObj)
The text was updated successfully, but these errors were encountered:
Consider this little benchmark:
The performance of
Vector{GapObj}(L)
is disappointing. I think it is because of theIdDict
we create and maintain, but for nought, at least in this case. Also note howcollect
is the fastest, but returns a suboptimal type.In this particular case, one can do quite a bit better:
Perhaps we can set up variants of our conversions which perform faster in "such" cases. Where it remains to be settled what exactly "such" cases are.... coming to mind are certainly:
T{S}
whereT
is a container likeVector
,Set
, ... andS
eitherGapObj
orGAP.Obj
orInt
.T{BigInt}
orT{fmpz}
but then it'd be a tradeoff in performance vs. memory usage, at least in principle. But it might actually better here, as not all "end users" may expect aliasing in these cases, and if someone starts to modify entries in the result in-place, they might be surprised... ?Even if we can't solve this in general, I think that at least the
T{GapObj}
case is important enough to deserve special treatment here. I.e. special methods forVector{GapObj}(x::GapObj)
and perhaps also forcollect(x::GapObj)
The text was updated successfully, but these errors were encountered: