I have an application where I want to use an OrderedDict (from OrderedCollections.jl) with subs, but some methods are too strictly typed. This PR widens the type from Dict to the more generic AbstractDict for the relevant methods.
Update: Turns out that I did not need this for my app, see below, but I think the changes are still useful.
My initial motivation for using an OrderedDict instead of just calling subs(eq, x => y) repeatedly and in the right order was that I thought the former is faster.
But it turned out that the benchmark I did was wrong, because of the following
a, b, c = symbols("a, b, c")
subs(a+b, a=>b, b=>c) # = 2 c
subs(a+b, Dict(a=>b,b=>c)) # = b + c
I think the issue is that the first version is translated to subs(subs(a+b, a=>b), b=>c), whereas the dict version somehow performs both substitutions at the same time.
I have an application where I want to use an
OrderedDict
(fromOrderedCollections.jl
) withsubs
, but some methods are too strictly typed. This PR widens the type fromDict
to the more genericAbstractDict
for the relevant methods.Update: Turns out that I did not need this for my app, see below, but I think the changes are still useful.
My initial motivation for using an
OrderedDict
instead of just callingsubs(eq, x => y)
repeatedly and in the right order was that I thought the former is faster. But it turned out that the benchmark I did was wrong, because of the followingI think the issue is that the first version is translated to
subs(subs(a+b, a=>b), b=>c)
, whereas the dict version somehow performs both substitutions at the same time.