Hi,
I got sum(genexp) working in cython-closures (not pushed yet), so here are
some timings. The Cython code (of this pretty bad benchmark) is:
def return_range_sum(int N):
return sum(i for i in range(N))
timeit "sum(i for i in xrange(10000))"
1000 loops, best of 3: 584 usec per loop
timeit "return_range_sum(10000)"
1000 loops, best of 3: 235 usec per loop
Note that the generated C code runs the loop in C but does the addition in
Python objects. I haven't found an easy way to drop this into C yet (the
transformation is done before type analysis), but given that it's faster
already, I think it's still worth it - and it adds a feature that we
currently don't support at all.
Stefan
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev