Le vendredi 23 juillet 2010 à 17:41 -0700, Brian Granger a écrit : > On Wed, Jul 21, 2010 at 1:15 PM, Aaron S. Meurer <asmeu...@gmail.com> wrote: > > First off, pragmatically speaking, is there a reason why you need to use > > the core Mul instead of writing your own custom Mul for the quantum stuff? > > I am just saying this because even though I agree that we need this change, > > changing anything in the core is very difficult and time consuming, because > > the code is so fragile, and you also have to pay close attention to speed > > concerns. > > I would very much like the option of using a custom Mul subclass, but > that is currently impossible in sympy. The reason is that my > expressions also have sympy scalars. Anytime one of those appears on > the left of a multiplication its __mul__ gets called and everything > becomes a Mul. To use custom Mul classes for anything, we need to > have something like the __array_priority that numpy has built into the > core.
I think this can be done with a careful implementation of double dispatch in __mul__ and __rmul__, so I don't see the point of this __array_priority. Though this implementation would require some sort of complete ordering of the classes, which is conceptually similar to an __array_priority, it doesn't have to appear explicitly in the code. Ronan -- You received this message because you are subscribed to the Google Groups "sympy" group. To post to this group, send email to sy...@googlegroups.com. To unsubscribe from this group, send email to sympy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sympy?hl=en.