2
없이 사용할 수 없습니다 :사이 썬 오류 : 파이썬에서 강제 변환은 다음 MCE 컴파일하려고 GIL
from libc.math import fabs
cdef inline double fmax(double x, double y) nogil:
return x if x > y else y
cdef inline double fsign(double x) nogil :
if x == 0.:
return 0.
elif x > 0.:
return 1.
else:
return - 1.
cdef inline double ST(double u, double x) nogil:
return fsign(x) * fmax(fabs(x) - u, 0.)
를 내가 얻을, 다른 오류 사이 :
Error compiling Cython file:
------------------------------------------------------------
...
else:
return - 1.
cdef inline double ST(double u, double x) nogil:
return fsign(x) * fmax(fabs(x) - u, 0.)
^
------------------------------------------------------------
test.pyx:18:35: Coercion from Python not allowed without the GIL
내가 단서가 무슨 일하지 않은, 내 관점에서 볼 때 모든 값은 double입니다 (float 일 수는 있지만 0은 float 일 수 있지만 double로 안전하게 승격 될 수 있음).
setup.py
은
from distutils.core import setup
from Cython.Build import cythonize
setup(
ext_modules=cythonize("*.pyx"),
)
편집 : 나에게 많은 도움이되지 않았다
test.pyx:18:35: Operation not allowed without gil
test.pyx:18:31: Calling gil-requiring function not allowed without gil
test.pyx:18:31: Accessing Python global or builtin not allowed without gil
test.pyx:18:33: Converting to Python object not allowed without gil
test.pyx:18:31: Constructing Python tuple not allowed without gil