I would like to perform cython
files compilation in parallel.
So, I take a look at Cython.Build
source file, and find the following signature for cythonize
function:
def cythonize(module_list, exclude=None, nthreads=0, aliases=None,
quiet=False, force=False, language=None,
exclude_failures=False, **options):
And the following comment about cythonize nthreads
option:
"For parallel compilation, set the 'nthreads' option to the number of
concurrent builds."
So I tried to use this option in my setup.py
file, like that:
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),
...)
But my .pyx
files are still compiled sequentially using 1 thread.
I do not understand what I am doing wrong here and how to use nthreads
option to perform cythonize
compilation in parallel ?
setup(..)
in several parallel processes, couldn't it have some unexpected side effects? – Shumway