This document provides examples of using Cython-generated code in
get started, run the following from directory
pip install scipy # For BLAS example pip install -e . python cython_main.py --help
You can import the
cython_examples module from a Python script or interpreter.
- You must include the following two lines at the top of any
#!python # cython: embedsignature=True, binding=True
- You cannot decorate Cython functions within a
*.pyxfile (there are ways around this, but creates a leaky abstraction between Cython and Python that would be very challenging to support generally). Instead, prefer the following in your Python code:
some_cython_func = ray.remote(some_cython_module.some_cython_func)
- You cannot transfer memory buffers to a remote function (see
example8, which currently fails); your remote function must return a value
- Have a look at
setup.pyfor examples of how to call, define, and build Cython code, respectively. The Cython documentation is also very helpful.
- Several limitations come from Cython’s own unsupported Python features.
- We currently do not support compiling and distributing Cython code to
rayclusters. In other words, Cython developers are responsible for compiling and distributing any Cython code to their cluster (much as would be the case for users who need Python packages like
- For most simple use cases, developers need not worry about Python 2 or 3, but users who do need to care can have a look at the
language_levelCython compiler directive (see here).