Skip to content

Instantly share code, notes, and snippets.

@ZGainsforth
Created July 8, 2014 20:46
Show Gist options
  • Save ZGainsforth/1dc30e2126954f85cb9f to your computer and use it in GitHub Desktop.
Save ZGainsforth/1dc30e2126954f85cb9f to your computer and use it in GitHub Desktop.
Minimal Cython implementation (modeled from training.enthought.com example)
def cyfib(int n):
cdef int a, b, i
a,b = 1,1
for i in range(n):
a,b = a+b, a
return a
import pyximport
pyximport.install()
from cyfib import cyfib
def fib(n):
a,b = 1,1
for i in range(n):
a,b = a+b, a
return a
print fib(5)
print cyfib(5)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment