There are several ways to create and build Cython code in Sage.
In the Sage Notebook begin any cell with
%cython. When you evaluate that cell,
It is saved to a file.
Cython is run on it with all the standard Sage libraries
automatically linked if necessary.
The resulting .so file is then loaded into your running
instance of Sage.
The functionality defined in that cell is now available
for you to use in the notebook. Also, the output cell has
a link to the C program that was compiled to create
the .so file.
Below we will denote notebook sessions as follows:
{{{
INPUT TEXT
///
OUTPUT TEXT
}}}
...
The triple braces delimit cells. You should not
actually type in the curly braces or triple forward
slashes.
Create an .spyx file and attach or load it
from the command line.
This is similar to creating a %cython cell
in the notebook but works completely from the command
line.
Create a .pyx file in the Sage library, add it to SAGE_ROOT/devel/sage/setup.py (note - you have to follow the
template of how something else in there is done - we simply haven't
had the time to properly document this process yet!), and type sage -br to build it. This is how much of the core arithmetic in
the Sage library is implemented.