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
# NOTE: for some reason, merely overloading this function causes allocations
# in Julia 1.9. This is not the case in 1.10, so presumably this is a bug.
# Therefore, allocation tests only are performed on >=1.10
function Base.setindex!(A::Array{T}, x::TempTPS, i1::Int) where {T<:TPS}
copy!(A[i1], x)
rel_temp!(x)
end
I think this only works "by accident", e.g., I suppose it could break with any Julia release, if Base decides to change its implementation regarding setindex! for Array.
It seems like type piracy, in some sense. Or perhaps it's function punning that might be confusing to users? Not sure TBH, but it definitely feels very bad.
There's another potential issue with the method signature, though an easily fixable one: it matches setindex!(::Array{Union{}}, ::TempTPS, ::Int), which is surely not intended. Fix: #136
The text was updated successfully, but these errors were encountered:
The intention here is to basically overload .= for setting an array of TPS equal to an array of TempTPS so that there are zero allocations of new TPS's - the TPSs originally in the array on the LHS are just changed in-place to be equal those by the temporaries.
This feature is useful for such mutable number types, but if you can think of a better way to handle this I would be happy to implement it.
I don't think you're allowed to do this:
GTPSA.jl/src/fastgtpsa/temptps.jl
Lines 132 to 138 in 29e2f83
I think this only works "by accident", e.g., I suppose it could break with any Julia release, if
Base
decides to change its implementation regardingsetindex!
forArray
.It seems like type piracy, in some sense. Or perhaps it's function punning that might be confusing to users? Not sure TBH, but it definitely feels very bad.
There's another potential issue with the method signature, though an easily fixable one: it matches
setindex!(::Array{Union{}}, ::TempTPS, ::Int)
, which is surely not intended. Fix: #136The text was updated successfully, but these errors were encountered: