I recently came across sentdex tutorial for cython. While trying out his tutorial codes the thing I noticed is how we will debug our cython code before compiling it.
The original code we can debug by running it example_original.py
in our interpreter.
#example_original.py
def test(x):
y = 0
for i in range(x):
y += i
return y
print test(20)
But the cythonized code dosent work. This is the two ways which I tried
1) py file
#example_cython.py
cpdef int test(int x):
cdef int y = 0
cdef int i
for i in range(x):
y += i
return y
print test(5)
Error
File "example_cython.py", line 3
cpdef int test(int x):
^
SyntaxError: invalid syntax
2) pyx file
#example_cython.pyx
cpdef int test(int x):
cdef int y = 0
cdef int i
for i in range(x):
y += i
return y
print test(5)
Error
./example_cython: not found
What is the right way to debug cython codes before compiling it?