[sympy] arg order

2011-05-27 Thread smichr
Does anyone have a better idea for how to canonicalize the args for Add (perhaps Mul, too). >>> from sympy.abc import * >>> from sympy import * >>> 3*x+6*y 3*x + 6*y >>> _.args (3*x, 6*y) >>> (x+2*y).args (2*y, x) >>> (2*x+2*y+z).args (2*y, z, 2*x) >>>

Re: [sympy] arg order

2011-05-27 Thread Aaron Meurer
Speed needs to be considered too. Aaron Meurer On Fri, May 27, 2011 at 6:22 AM, smichr wrote: > Does anyone have a better idea for how to canonicalize the args for > Add (perhaps Mul, too). > >    >>> from sympy.abc import * >    >>> from sympy import * >    >>> 3*x+6*y >    3*x + 6*y >    >>> _

Re: [sympy] arg order

2011-05-27 Thread Chris Smith
The reason for the apparent arbitrariness is that Add uses key=hash (for speed) while Mul uses Basic.compare. -- You received this message because you are subscribed to the Google Groups "sympy" group. To post to this group, send email to sympy@googlegroups.com. To unsubscribe from this group, s

Re: [sympy] arg order

2011-05-27 Thread Mateusz Paprocki
Hi, On 27 May 2011 23:27, Chris Smith wrote: > The reason for the apparent arbitrariness is that Add uses key=hash (for > speed) while Mul uses Basic.compare. It seems we just overlooked Basic.compare in Mul. I git blame sympy/core/mul.py and the line with Basic.compare didn't change since the

Re: [sympy] arg order

2011-05-27 Thread Mateusz Paprocki
Hi, On 27 May 2011 14:22, smichr wrote: > Does anyone have a better idea for how to canonicalize the args for > Add (perhaps Mul, too). > >>>> from sympy.abc import * >>>> from sympy import * >>>> 3*x+6*y >3*x + 6*y >>>> _.args >(3*x, 6*y) >>>> (x+2*y).args >(2*y,

Re: [sympy] arg order

2011-05-28 Thread Mateusz Paprocki
Hi, On 28 May 2011 08:45, Mateusz Paprocki wrote: > Hi, > > On 27 May 2011 23:27, Chris Smith wrote: > >> The reason for the apparent arbitrariness is that Add uses key=hash (for >> speed) while Mul uses Basic.compare. > > > It seems we just overlooked Basic.compare in Mul. I git blame > sympy/

Re: [sympy] arg order

2011-06-01 Thread Aaron Meurer
+1 to as_ordered_args. I think for most places that use .args the order doesn't really matter. Those should use .args, and the slower .as_ordered_args should only be used in the cases where the order does matter. It would be nice if there were a function that were just as fast as hash that wasn'