【发布时间】:2016-10-27 02:25:09
【问题描述】:
我想并行执行cython 文件编译。
所以,我查看Cython.Build 源文件,并找到cythonize 函数的以下签名:
def cythonize(module_list, exclude=None, nthreads=0, aliases=None,
quiet=False, force=False, language=None,
exclude_failures=False, **options):
还有以下关于 cythonize nthreads 选项的评论:
"For parallel compilation, set the 'nthreads' option to the number of
concurrent builds."
所以我尝试在我的setup.py 文件中使用这个选项,就像这样:
from setuptools import setup
from Cython.Build import cythonize
from Cython.Distutils.extension import Extension
EXTENSIONS = [Extension(...)
...
Extension(...)]
setup(name='...',
...
ext_modules=cythonize(EXTENSIONS, nthreads=8),
...)
但我的.pyx 文件仍然使用 1 个线程按顺序编译。
我不明白我在这里做错了什么以及如何使用nthreads 选项并行执行cythonize 编译?
【问题讨论】:
标签: python python-2.7 cython cythonize