Nathann Cohen wrote: > Thank you very much for your answers !!! I will try to fix these small > issues along with real patches, as I go over the code in the Graph > Section... Most of the time lists are used to represent sets, and I > guess it can be improved in a few cases :-)
If you know the universe of elements, or even better, if your universe of elements is 0,...,n-1, then using the Sage Bitset class can often be faster than using Python sets. See these timings from http://trac.sagemath.org/sage_trac/ticket/5800. In each test, the first timing is using Sage bitsets, the second is using Python sets. You can see there is an order of magnitude difference in these examples. sage: a=Bitset([3*i for i in range(100)]) sage: b=Bitset([4*i for i in range(100)]) sage: d=set([4*i for i in range(100)]) sage: c=set([3*i for i in range(100)]) sage: %timeit a|b 1000000 loops, best of 3: 1.55 盜 per loop sage: %timeit c|d 100000 loops, best of 3: 17.6 盜 per loop sage: %timeit a-b 100000 loops, best of 3: 1.53 盜 per loop sage: %timeit c-d 100000 loops, best of 3: 10.4 盜 per loop Note that these timings are probably drastically reduced if you access the bitsets from Cython, rather than Python. This is how a lot of the C graph backend works. Jason -- Jason Grout -- 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 URL: http://www.sagemath.org