Skip to content

use more generic types #261

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 13, 2023
Merged

Conversation

fatteneder
Copy link
Contributor

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.

@isuruf
Copy link
Member

isuruf commented Apr 13, 2023

Thanks

@isuruf isuruf merged commit d2b4443 into symengine:master Apr 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants