On-the-fly generation of compiled extensions

sage.misc.cython_c.cython_compile(code, verbose=False, compile_message=False, make_c_file_nice=False, use_cache=False)

Given a block of Cython code (as a text string), this function compiles it using a C compiler, and includes it into the global scope of the module that called this function.

The following pragmas are available:

  • clang - may be either c or c++ (or C or C++) indicating whether a C or C++ compiler should be used.
  • clib - additional libraries to be linked in, the space separated list is split and passed to distutils.
  • cinclude - additional directories to search for header files. The space separated list is split and passed to distutils.
  • cfile - additional C or C++ files to be compiled. Also, $SAGE_ROOT is expanded, but other environment variables are not.
  • cargs - additional parameters passed to the compiler

For example:

#clang C++
#clib givaro
#cinclude /usr/local/include/
#cargs -ggdb
#cfile foo.c

AUTHOR: William Stein, 2006-10-31