[Cython] __next__ | not being able to use cpdef
Stefan Behnel
stefan_ml at behnel.de
Thu Dec 11 10:13:37 CET 2008
Robert Bradshaw wrote:
> %cython
>
> cdef foo_c():
> pass
>
> def do_loop_c_call(int n, int m):
> cdef int i, j
> for i in range(n):
> for j in range(m):
> foo_c()
> [...]
> sage: time do_loop_c_call(5000, 500)
> CPU time: 0.00 s, Wall time: 0.00 s
>
> The moral of the story is that the loop overhead can be reduced to
> essentially a clock cycle or two per iteration (nanoseconds)
Have you looked at the assembly that the above code compiles into? I
wouldn't be surprised if the C compiler inlined the call to foo_c(), and
then removed the entire loop as useless code.
Stefan
More information about the Cython-dev
mailing list