projects
/
cython.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
9185baa
)
little test for comparing loop code
author
Stefan Behnel
<scoder@users.berlios.de>
Thu, 6 Mar 2008 08:27:04 +0000
(09:27 +0100)
committer
Stefan Behnel
<scoder@users.berlios.de>
Thu, 6 Mar 2008 08:27:04 +0000
(09:27 +0100)
tests/run/addloop.pyx
[new file with mode: 0644]
patch
|
blob
diff --git a/tests/run/addloop.pyx
b/tests/run/addloop.pyx
new file mode 100644
(file)
index 0000000..
25a82ac
--- /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