#16296: Speed improvements for categories with axioms
-------------------------------------+-------------------------------------
Reporter: SimonKing | Owner:
Type: enhancement | Status: new
Priority: major | Milestone: sage-6.3
Component: categories | Resolution:
Keywords: cython | Merged in:
performance categories | Reviewers:
Authors: | Work issues:
Report Upstream: N/A | Commit:
Branch: | d42dc9c37015b51fac7a089654044dd132c75000
u/SimonKing/ticket/16296 | Stopgaps:
Dependencies: #10963, #15801 |
-------------------------------------+-------------------------------------
Comment (by SimonKing):
Indeed:
{{{
#!python
def test1(list L):
cdef int i,j
cdef int max_i = len(L)
for i in range(max_i):
if any(100 in L[j] for j in range(max_i) if j!=i):
continue
def test2(list L):
cdef int i,j
cdef int max_i = len(L)
for i in range(max_i):
if any(100 in <set>(L[j]) for j in range(max_i) if j!=i):
continue
cpdef test3(list L):
cdef int i,j
cdef int max_i = len(L)
cdef bint cont
for i in range(max_i):
cont = False
for j from 0<=j<i:
if 100 in <set>(L[j]):
cont = True
break
if cont:
continue
for j from i<j<max_i:
if 100 in <set>(L[j]):
break
}}}
yields
{{{
sage: L = [set([randint(0,10000) for i in range(200)]) for j in
range(200)]
sage: %timeit test1(L)
100 loops, best of 3: 2.5 ms per loop
sage: %timeit test2(L)
100 loops, best of 3: 2.5 ms per loop
sage: %timeit test3(L)
1000 loops, best of 3: 1.25 ms per loop
}}}
So, let's do it like this. I hope I am not mistaken that what is happening
inside `test3()` is equivalent to the "any" clause in the other two
functions.
--
Ticket URL: <http://trac.sagemath.org/ticket/16296#comment:13>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica,
and MATLAB
--
You received this message because you are subscribed to the Google Groups
"sage-trac" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-trac.
For more options, visit https://groups.google.com/d/optout.