Created
November 2, 2018 10:41
-
-
Save MrfksIv/93b8babada106fee821b9a1a704a7138 to your computer and use it in GitHub Desktop.
The fibonacci function written in Cython
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def fib(int n): | |
cdef int i | |
cdef double a=0.0, b=1.0 | |
for i in range(n): | |
a, b = a+b, a | |
return a |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from distutils.core import setup | |
from Cython.Build import cythonize | |
setup(ext_modules = cythonize('fibonacci_cython.pyx') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment