Learning Cython - Basics



在jupyter notebook中学习cython

首先导入cython

In [1]:
%load_ext Cython
In [1]:
%%cython
# distutils: language=c 

def test(short test, char arg[]):
    return test, arg

print(test(1.1, b'ab'))
UsageError: Cell magic `%%cython` not found.
In [8]:
%%cython
# distutils: language=c
cdef test(short test):
    for i in range(10):
        test = test + i
    return test
    
print(test(12))

评论