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

_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev

Reply via email to