On Thu, Aug 20, 2009 at 4:11 AM, Golam Mortuza Hossain<gmhoss...@gmail.com> wrote: > > Hi, > > It takes too long to check whether x is in a list in new symbolics > > --------- > sage: var('x,x1,x2,x3,x4') > (x, x1, x2, x3, x4) > sage: f = function('f') > sage: mylist = [x1,x2,x3,x4,f(x1),f(x2),f(x3),f(x4)] > > sage: timeit('x in mylist') > 5 loops, best of 3: 461 ms per loop > -------- > > If your program needs to check it couple of more times > ---------- > sage: timeit('x in mylist') > 5 loops, best of 3: 1.26 s per loop > sage: timeit('x in mylist') > 5 loops, best of 3: 3.4 s per loop > ---------- > > For a comparison > --------- > sage: timeit('x1 in mylist') > 625 loops, best of 3: 473 ns per loop > --------- > > Reason for this huge discrepancy stems from the fact that > except for last example, in all previous cases maxima is called > to check the equality. > > Thus it seems, new symbolics depends on maxima for basic > operations even now. > > I don't know the rationale behind this design given pynac has > a method to compare two symbolic expression (ex1.is_equal(ex2)). > > In any case, this design ensures writing a program in new symbolics > where some basic tests like "if x in list" needs to done, is no better than > old symbolics. >
That's not for any list, but it is for the one you constructed. I think to get the new symbolics out at some point we finally gave in and made the compare method fall back to Maxima (in case several pynac-based methods failed) so that massive amounts of user code and doctests wouldn't break. Fixing this is obviously something that needs to be done. Hopefully you will do it! :-) William --~--~---------~--~----~------------~-------~--~----~ To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URLs: http://www.sagemath.org -~----------~----~----~----~------~----~------~--~---