Module: sage.interfaces.sage0
This is an expect interface to another copy of the SAGE interpreter.
Module-level Functions
) |
s) |
) |
) |
Class: Sage
INPUT: server - (optional); if specified runs SAGE on a remote machine with address. You must have ssh keys setup so you can login to the remote machine by typing "ssh remote_machine" and no password, e.g.: cd; ssh-keygen -t rsa; scp .ssh/id_rsa.pub remote_machine:.ssh/authorized_keys2
The version of SAGE should be the same as on the local machine, since pickling is used to move data between the two SAGE process.
We create an interface to a copy of SAGE. This copy of SAGE runs as an external process with its own memory space, etc.
sage: s = Sage()
Create the element 2 in our new copy of SAGE, and cubeit.
sage: a = s(2) sage: a^3 8
Create a vector space of dimension
, and compute its generators:
sage: V = s('Q^4') sage: V.gens() ((1, 0, 0, 0), (0, 1, 0, 0), (0, 0, 1, 0), (0, 0, 0, 1))
Note that V is a not a vector space, it's a wrapper around an object (which happens to be a vector space), in another running instance of SAGE.
sage: type(V) <class 'sage.interfaces.sage0.SageElement'> sage: V.parent() Sage sage: g = V.0; g (1, 0, 0, 0) sage: g.parent() Sage
We can still get the actual parent by using the name attribute of g, which is the variable name of the object in the child process.
sage: s('%s.parent()'%g.name()) Vector space of dimension 4 over Rational Field
Note that the memory space is completely different.
sage: x = 10 sage: s('x = 5') 5 sage: x 10 sage: s('x') 5
We can have the child interpreter itself make another child SAGE process, so now three copies of SAGE are running:
sage: s3 = s('Sage()') sage: a = s3(10) sage: a 10
This
is in a subprocess of a subprocesses of your original SAGE.
sage: _ = s.eval('%s.eval("x=8")'%s3.name()) sage: s3('"x"') 8 sage: s('x') 5 sage: x 10
The double quotes are needed because the call to s3 first evaluates
its arguments using the s interpeter, so the call to s3 is passed
s('"x"')
, which is the string "x"
in the s interpreter.
self, [maxread=None], [script_subdirectory=True], [logfile=None], [preparse=user], [server=10000]) |
Functions: console,
eval,
get,
new,
preparse,
quit,
set,
version
self, line) |
Send the code x to a second instance of the SAGE interpreter and return the output as a string.
This allows you to run two completely independent copies of SAGE at the same time in a unified way.
self, var) |
Get the value of the variable var.
self, var, value) |
Set the variable var to the given value.
Special Functions: __call__,
__reduce__,
_contains,
_get_object_from_server_tmpfile,
_is_true_string,
_object_class,
_quit_string,
_remote_tmpfile,
_send_tmpfile_to_server
Class: SageElement
Special Functions: _sage_
Class: SageFunction
Special Functions: __call__,
__repr__
See About this document... for information on suggesting changes.