On Tue, Jul 3, 2012 at 6:32 PM, Sergiu Ivanov
<unlimitedscol...@gmail.com> wrote:
> On Tue, Jul 3, 2012 at 4:03 PM, Matthew Rocklin <mrock...@gmail.com> wrote:
>> I've found that sorting the args at creation time solves lots of problems. I
>> have not found that this sorting causes any performance issues in SymPy.
>> Sorting is fairly efficient and no one uses FiniteSets for huge sets.
>
> I will make the confession that it's not the first time that I think
> that dropping initial element sorting in FiniteSet wasn't probably
> that very cool an idea performance-wise.

I guess the time has come to bump this thread :-)

I will remind the essence of the matter.  Some time ago the
constructor of FiniteSet has been modified to _not_ sort .args.  This
has created the necessity to explicitly sort FiniteSet's on many
occasions.

Currently, however, I have run in yet another occasion where arbitrary
ordering of FiniteSet's comes in the way.  FiniteSet relies on
Basic.sort_key to construct the sort key.  Basic.sort_key, in its
turn, traverses .args and creates a sort key which _depends_ on the
ordering of .args.  I have stumbled over a situation where this
actually influences how collections containing FiniteSet's are
ordered.  I really don't like the idea of sorting .args every time a
sort key is required, and I have not managed to come up with a better
way to approach the sort key problem.

Therefore, there are basically two ways out:

1. Restore the old behaviour of FiniteSet, when it used to sort .args
   at creation, but rely on default_sort_key to sort the items instead
   of a custom function.

2. Invent a good way to create a compliant sort key independently of
   the ordering of .args.

In support of (1) I would like to point out once again that the fact
that a set is an unordered collection should normally be interpreted
as an absence of guarantee of a certain ordering, rather then an
prohibition to have any ordering.

Sergiu

-- 
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, send email to 
sympy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sympy?hl=en.

Reply via email to