On May 14, 1:08 am, Rado <rki...@gmail.com> wrote:
> The bug is almost trivial. The code
>
> verts = data.keys()
> ....
> for u in data:
> verts.union([v for v in data[u] if v not in verts])
>
> is slowing down because in python searching in lists is slow. If we
> use "verts = set(data.keys())" the code speeds up tremendously.
Nice catch. No idea if this is the fix, but we will see I guess ;).
> sage: D={}
> sage: for i in xrange(10^3):
> ....: D[i]=[i+1,i-1]
> ....:
> sage: timeit('g=Graph(D)')
> 5 loops, best of 3: 79.6 ms per loop
>
> Before I submit a patch how do I run the the graph theory doctests to
> make sure nothing else is broken by changing verts from list to set?
Run "make check" in $SAGE_ROOT or
./sage -tp 1 devel/sage
where the number behind -tp is the number of tests run in parallel.
> Rado
Cheers,
Michael
--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to sage-devel@googlegroups.com
To unsubscribe from this group, send 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
-~----------~----~----~----~------~----~------~--~---