3.1 Sage Preparsing
The following is a list of files relevant to preparsing through which
control flows when Sage is run:
SAGE_ROOT/sage-sage
,
SAGE_ROOT/sage-preparse
,
SAGE_ROOT/devel/sage/sage/misc/preparser.py
The file preparser.py is contains the Sage preparser code and the
following are some notes from the aforementioned file
- In Sage methods can also be called on integer and real literals
(note that in pure Python this would be a syntax error).
- Note that calling methods on int literals in pure Python is a
syntax error, but Sage allows this for Sage integers and reals,
because users frequently request it.
- Raw literals are not preparsed, which can be useful from an
efficiency point of view. Just like Python ints are denoted by an
L, in Sage raw integer and floating literals are followed by an ``r''
(or ``R'') for raw, meaning not preparsed.
- Raw literals can be very useful in certain cases. For instance,
Python integers are typically much more efficient than Sage integers
when they are very small; large Sage integers are much more
efficient than Python integers, since they are implemented using the
GMP C library -- see section 8.3.
Consult preparser.py for details about Sage preparsing, examples involving raw literals, etc.
When foo.sage is loaded in a sage session, a preparsed version of
foo.sage is created titled foo.py. The beginning of foo.py states:
This file was *autogenerated* from the file foo.sage.
Release 2008.07.11, documentation updated on July 11, 2008.
See About this document... for information on suggesting changes.