On Mon, Jul 23, 2012 at 9:10 PM, Joachim Durchholz <[email protected]> wrote: > 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.
Yes, I guess you are all right about my suggestion; it's going to make FiniteSet much more fragile. > 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. That might an issue, indeed. > In other words, do the benchmarks before you optimize. That's obviously a very good point. > In this case, I'd want to avoid laziness anyway. > It's just too much of a bug spawner. Yeah, I see. Sergiu -- 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.
