LinuxCommandLibrary

cythonize

TLDR

Compile Cython file

$ cythonize -i [module.pyx]
copy
Compile with build directory
$ cythonize -b [module.pyx]
copy
Compile multiple files
$ cythonize -i [*.pyx]
copy
Compile with parallelism
$ cythonize -j [4] -i [module.pyx]
copy
Force recompilation
$ cythonize -f -i [module.pyx]
copy
Annotate with HTML
$ cythonize -a [module.pyx]
copy

SYNOPSIS

cythonize [options] files...

DESCRIPTION

cythonize compiles Cython source files (.pyx) into C extension modules. Cython is a superset of Python that enables C-level performance through static typing and direct C API access.
The tool handles the full compilation pipeline: generating C code, compiling with a C compiler, and building importable Python modules.

PARAMETERS

-i, --inplace

Build extensions in place.
-b, --build
Build using temporary build directory.
-j n
Parallel compilation jobs.
-f, --force
Force recompilation.
-a, --annotate
Generate HTML annotation.
-3
Use Python 3 syntax.
-X directive
Set Cython directive.
-s option
Set compiler option.
--cplus
Generate C++ code.

CAVEATS

Requires C compiler installed. Platform-specific extensions not portable. Annotation helps identify Python-heavy code. Some Python features slower in Cython.

HISTORY

Cython evolved from Pyrex, created by Greg Ewing in 2002. The Cython fork by Robert Bradshaw and Stefan Behnel added Python compatibility and features. The cythonize command provides a convenient wrapper over the compilation process.

SEE ALSO

python(1), gcc(1), pip(1), numba(1)

Copied to clipboard