Why does Cython break Python?

I just started using Cython and am trying to implement a simple Fibonacci function as described here:

http://docs.cython.org/src/tutorial/cython_tutorial.html

The problem is, when I try to run a function for a given input, in Spyder, the kernel dies and python crashes.

Specifically, if I open Spyder and run

%%file cython_fib.pyx
def fib(n):

    a, b = 0, 1
    while b < n:

        print b,
        a, b = b, a + b

      

then the cython_fib.pyx file is generated. Then I can run

import pyximport; pyximport.install()
import cython_fib 

      

to import the Cython function cython_fib. At this point in the process, Spyder uses about 80% of its memory. When I try to call a function,

cython_fib.fib(2000)

      

IPython console in Spyder throws an error

It seems the kernel died unexpectedly. Use 'Restart kernel' to continue using this console.

      

repeatedly.

What is causing this crash? Obviously using Cython uses a lot of memory, but that shouldn't be a problem for such a simple example.

I am using Anaconda 2.0.1 with Python 3.4 on Windows 7.

+3
python cython


source to share


No one has answered this question yet

Check out similar questions:

9540
What does the yield keyword do?
5504
Does Python have a ternary conditional operator?
5433
What if __name__ == "__main__": do?
5231
What are metaclasses in Python?
4473
Calling an external command in Python
3790
How can I safely create a subdirectory?
3602
Does Python have a substring method "contains"?
3119
What is the difference between Python list methods that are appended and expanded?
2818
Finding the index of an element by specifying the list that contains it in Python
2568
How to find the current time in Python



All Articles
Loading...
X
Show
Funny
Dev
Pics