我想用以下类对python模块进行cythonize:
class C:
def __init__(self, x):
self.x = x
@staticmethod
def f(k):
return k
def g(self, k):
return self.x, k
安装 cythonized 模块后,我正在尝试执行代码:
from dask import delayed, multiprocessing
c = C(3)
l = []
for i in range(10):
l.append(delayed(c.f)(i))
results = delayed(l).compute(num_workers=2, get=multiprocessing.get)
我有酸洗错误(静态和非静态方法相同):
~/anaconda/envs/cython_env/lib/python3.6/site-
packages/cloudpickle/cloudpickle.py in save_global(self, obj, name,
pack)
621 self.save_dynamic_class(obj)
622 else:
--> 623 raise pickle.PicklingError("Can't pickle %r" % obj)
624
625 dispatch[type] = save_global
PicklingError: Can't pickle <cyfunction C.f at 0x113582b10>
为什么会这样?