From 1bb1afb21366bbcc5d70606794cbaf7a3b2527c0 Mon Sep 17 00:00:00 2001 From: Stefan Behnel Date: Thu, 6 Mar 2008 09:27:04 +0100 Subject: [PATCH] little test for comparing loop code --- tests/run/addloop.pyx | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 tests/run/addloop.pyx 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 -- 2.26.2