From: Stefan Behnel Date: Thu, 6 Mar 2008 08:27:04 +0000 (+0100) Subject: little test for comparing loop code X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=1bb1afb21366bbcc5d70606794cbaf7a3b2527c0;p=cython.git little test for comparing loop code --- diff --git a/tests/run/addloop.pyx b/tests/run/addloop.pyx new file mode 100644 index 00000000..25a82ac2 --- /dev/null +++ b/tests/run/addloop.pyx @@ -0,0 +1,33 @@ +__doc__ = """ + >>> x = 1 + >>> for i in range(10): + ... x = x + i + >>> x + 46 + + >>> add_pyrange(10) + 46 + >>> add_py(10) + 46 + >>> add_c(10) + 46 +""" + +def add_pyrange(max): + x = 1 + for i in range(max): + x = x + i + return x + +def add_py(max): + x = 1 + for i from 0 <= i < max: + x = x + i + return x + +def add_c(max): + cdef int x,i + x = 1 + for i from 0 <= i < max: + x = x + i + return x