Multiple dispatch in SymPy

21 views
Skip to first unread message

Francesco Bonazzi

unread,
Jun 24, 2016, 7:52:15 AM6/24/16
to sympy
Hi,

are there any actual intentions of ever introducing multiple dispatch support to SymPy? Has the idea been completely abandoned?

I would like to have it as a dependency, some SymPy code could be made much more readable with it.

For those who are unfamiliar with the topic, some time ago we had this library developed for the purpose:

http://multiple-dispatch.readthedocs.io/en/latest/

https://github.com/mrocklin/multipledispatch

Aaron Meurer

unread,
Jun 24, 2016, 12:44:45 PM6/24/16
to sy...@googlegroups.com
What code specifically do you want to use it in?

In my experience, dispatching in SymPy functions happens by expression
type, which is often reflected by Python class, but not always. A
pattern matching based dispatching system would be more useful in my
opinion.

Aaron Meurer
> --
> You received this message because you are subscribed to the Google Groups
> "sympy" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to sympy+un...@googlegroups.com.
> To post to this group, send email to sy...@googlegroups.com.
> Visit this group at https://groups.google.com/group/sympy.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/sympy/ec315a80-a33e-4dcb-a4f8-5f70af359cca%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Francesco Bonazzi

unread,
Jun 24, 2016, 6:05:06 PM6/24/16
to sympy
I was mulling over the possibility of adding support for series expansion of indexed objects and/or multivariate series.

The _eval_nseries method could be dispatched over its second argument (second means the one after self).

The alternative would be the classical if isinstance( ... ), which SymPy is full of. In this case, it would be necessary to rewrite almost all of the _eval_nseries around.

Aaron Meurer

unread,
Jun 24, 2016, 7:02:41 PM6/24/16
to sy...@googlegroups.com
If it's the same logic in every function, it should be put in the main
series() method that calls _eval_nseries.

Aaron Meurer
> https://groups.google.com/d/msgid/sympy/c59ee0a6-df47-4095-9f7c-46eb83d3327d%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages