- Design: Think about what your program will do and how that fits into the
structure of Sage. In particular, much of Sage is implemented in
the object-oriented language Python, and there is a hierarchy of
classes that organize code and functionality. It is surprisingly painful and difficult to create some Python classes,
then realize that much functionality should be factored out into
base classes, and to do it . So try to get the structure right the first time.
For example, if you implement elements of a ring your class should
derive from
sage.structure.element.RingElement.
- Coding: Code it up, following the conventions in
Chapter 2. Make the basic structure and
interface for what you're doing in Python. You can use any of the
following languages to implement the hard parts: Python, C/C++,
Cython, Fortran 95, GAP, Singular, and GP/PARI. You can also use the mwrank,
GSL, NTL, and PARI C/C++ libraries. (And if you are OK with your code
depending on optional Sage packages, you can use Octave, or
even Magma, Mathematica, or Maple.) For readability and usability
it is best to use Sage when possible. On the other hand, for
efficiency reasons it is often crucial to use a compiled language or
an existing library or program--do not reinvent the wheel or write
code that is so slow as to be only a toy.
- Documentation: Document every Python function that you've
defined,
- Testing: Liberally include examples in your source code. See
Chapter 4.3 for more on automated testing of examples.
- (Optional) Write a file that generates random input to test (and
break!) your code with the intention of making it robust (See
Chapter 3.2).
- (Optional) Send your package to the
sage-devel
Google group
for inclusion in Sage, or make a standalone
spkg (see Chapter 3.3).
Release 2008.07.11, documentation updated on July 11, 2008.
See About this document... for information on suggesting changes.