Am 22.07.2012 22:07, schrieb Sergiu Ivanov:
Now, I do admit that not every use case of FiniteSet implies storing
it in a container. Therefore, perhaps, we could go with a lazy
approach: don't sort .args at FiniteSet creation; however, whenever a
certain order of .args is required, sort it and leave it like that
afterwards. On the one hand, this will bring in sorting strictly when
needed and, on the other hand, it will avoid the sorting in use cases
when it is not required.
Do you think that's a better approach?
It would complicate the codebase since you'd have to be 150% sure that
you catch all flows that might change .args. And whenever somebody
writes a subclass that does anything interesting with .args, there's a
good probability of screwing the sort up anyway.
It could even slow downthings. Whenever you need sorted .args, you need
to check a flag that tells you whether they are sorted already. Having
this check running repeatedly may add up to more CPU cycles than sorting
right at creation time.
In other words, do the benchmarks before you optimize.
In this case, I'd want to avoid laziness anyway.
It's just too much of a bug spawner.
--
You received this message because you are subscribed to the Google Groups
"sympy" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sympy?hl=en.