Removing the ordering is not a straightforward thing to do. There is
an important detail that depends on the ordering, which is that
something like x*y == y*x works because it assumes that the terms are
in canonical order, so it just compares them directly. And even
outside of __eq__ itself there may be other places that implicitly
make use of this fact. There's also a further complication which is
that for Add and Mul, any purely numeric part (i.e., the Rational or
Float term if it is nonzero) is always the first term in the args, and
many things rely on this fact.

This is a laudable change to make though. If we can somehow remove the
ordering from the core entirely (although I'm not even sure if that's
doable from a backwards compatibility point of view), it would also
improve the performance, since right now every Add and Mul that gets
created has to call sort() its arguments, which not only has to do the
sorting algorithm but it has to compute a canonical sort key for each
term. A good place to start is to look at And and Or, which go sort of
half way and don't sort their args until you actually request .args
(they also have ._argset which is a frozenset of the args).

Aaron Meurer

On Wed, Apr 20, 2022 at 10:50 AM Jonathan Gutow <gu...@uwosh.edu> wrote:
>
> Sympy orders symbols in ASCII order in equations. That is something I too 
> would like to have changed, but have not had the time to determine if any of 
> sympy depends on this canonical ordering. I suspect it is taken advantage of 
> in substitution and other related operations.
>
> On Apr 20, 2022, at 10:15 AM, Andre Bolle <andrebo...@gmail.com> wrote:
>
> You don't often get email from andrebo...@gmail.com. Learn why this is 
> important
>
> CAUTION: This email originated from outside of the organization. Do not click 
> links or open attachments unless you recognize the sender and know the 
> content is safe.
>
>
> We all know F=ma. But when doing a "Eqn(F, m * a)" one gets "๐น=๐‘Ž๐‘š ". Is there 
> a hinting system? i.e. If there's both an "a" and an "m" in a term, put the m 
> before the a.
>
> before(m,a)
> Andrรฉ
>
> --
> 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+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/sympy/dbb81668-ffaf-46bc-8e5a-02e262de49e1n%40googlegroups.com.
>
>
> --
> 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+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/sympy/26DC4101-67E2-45A7-94A6-EA9CC094C2CE%40uwosh.edu.

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/CAKgW%3D6J07itPZA9oH%2BJO34%2BqHjdYw%2BDy-TTVitE1mbr8SXy6sg%40mail.gmail.com.

Reply via email to