I'm sorry, I know I'm somewhat late to the party, and replying at this position in the thread is rather arbitrary, but how about the following:

1) don't sort .args at creation time (ronan has made good arguments for
   this, imho)
2) add a property .sorted_args to FiniteSet
   This could just return sorted(self.args, key=whatever) for now.
3) Anywhere you need sorted arguments (for example in the sort key, and
   for printing), use .sorted_args. Else use .args.
4) If we experience major slowdown in some use of .sorted_args,
   investigate if manual caching yields improvement.
5) PROFIT

As an expansion of step 4, most of which has already been said elsewhere: Since sympy objects are inherently immutable, the cache can be as dumb as using a self._sorted_args member which is initially set to None. The only problem I see with this is that myset.class(*myset.args) will clear the cache. Not sure how much of an issue that is.

Tom

--
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