我正在寻找合并一些cython来加速我的代码。 我在Jupyter中遇到了运行Cython代码的问题。在Jupyter cdef运行Cython
单元1:
%%cython
cdef fuc():
cdef int a = 0
for i in range(10):
a += i
print(a)
小区2:
fuc()
错误:
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
<ipython-input-48-10789e9d47b8> in <module>()
----> 1 fuc()
NameError: name 'fuc' is not defined
,但如果我这样做,它工作正常。
%%cython
def fuc():
cdef int a = 0
for i in range(10):
a += i
print(a)
看起来像cdef在Jupyter中使用不同,我怎么能在Jupyter笔记本中使用cdef?