我嘗試重現上用Cython教程一些例子來學習用Cython:爲什麼我在Cython下得到這個警告?
http://docs.cython.org/en/latest/src/tutorial/external.html
我認爲以下兩個警告都沒有關係。因此2個qestions:
(1)
以此爲輸入
蟒蛇setup.py build_ext --inplace -c的mingw32
from libc.math cimport sin
cdef extern from "math.h":
cdef double sin(double x)
cpdef double f(double x):
return sin(x*x)
cpdef test(double x):
return f(x)
我得到:
D:\python\cython>python setup.py build_ext --inplace -c mingw32
Compiling primes.pyx because it changed.
[1/1] Cythonizing primes.pyx
warning: primes.pyx:4:19: Function signature does not match previous declaration
running build_ext
building 'primes' extension
C:\MinGW\bin\gcc.exe -mdll -O -Wall -IC:\Python34\include -IC:\Python34\include -c primes.c -o build\temp.win32-3.4\Release\primes.o
writing build\temp.win32-3.4\Release\primes.def
C:\MinGW\bin\gcc.exe -shared -s build\temp.win32-3.4\Release\primes.o build\temp.win32-3.4\Release\primes.def -LC:\Python34\libs -LC:\Python34\PCbuild -lpython34 -lmsvcr100 -o D:\python\cython\primes.pyd
D:\python\cython>
爲什麼警告「功能簽名與以前的聲明不符」?
(2)
當我宣佈
cdef extern from "math.h":
cpdef double sin(double x)
我得到額外的警告
warning: primes.pyx:4:20: Function 'sin' previously declared as 'cpdef'
然而,正是給予相同的方式爲例章「外部的聲明「的鏈接頁面。在導入模塊的python模塊中,sin不在包下。哪裏有問題?
本教程中的說明是:
Note that you can easily export an external C function from your Cython module by declaring it as cpdef. This generates a Python wrapper for it and adds it to the module dict.
_「我認爲以下兩個警告是不相關的,因此有兩個問題:」_每個問題一個問題,請您理解 –