// test.c
long long run(long long n) {
long long s = 0;
for (long long i=0;i<n;i++) {
s += i;
}
return s;
}
# test.pyx
cdef extern from "test.c":
long long run(long long n)
def cysum(long long n):
cdef long long s
s = run(n)
return s
# setup.py
from setuptools import setup
from Cython.Build import cythonize
setup(
ext_modules=cythonize('test.pyx','test.c')
)
python setup.py build_ext --inplace