Created
June 26, 2018 07:32
-
-
Save kigawas/cc4f84cb8c51a0fa92448e85da603d7b to your computer and use it in GitHub Desktop.
Cython example of multiple pyx files
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
cdef int _fib(int n): | |
cdef int i | |
cdef int a=0, b=1 | |
for i in range(n): | |
a, b = a + b,a | |
return a | |
def fib(n): | |
return _fib(n) |
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
import a | |
def caller(n): | |
return a.fib(n) |
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('./*.pyx')) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Run:
python3 setup.py build_ext --inplace
Test in ipython or python shell like: